Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Servlet/JSP/JSF/JavaFX Script  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
reply to postflat modethreaded modego to previous topicgo to next topicgo to back
作者 Re::-O求助 JSP中通过JDBC连接SQL SERVER 的问题 [Re:longchuan]
wt_adam





发贴: 6
于 2006-08-07 15:20 user profilesend a private message to userreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
为什么这么多人都用Microsoft的驱动呢,不过Microsoft的驱动我也试过,也可以,不过我正常都用jtds.jar
这个文件一定要放在java_home\jre\lib\ext,也不知道什么原因,理论上放在WEB-INF/lib/下就可以了,classpath下都可以,给你一个代码,在你的机器上测试一下

import java.sql.*;

public class Dbtest {

Connection con;
Statement sta;
ResultSet rs;

String driver;
String url;
String user;
String pwd;

public Dbtest() {
driver = "net.sourceforge.jtds.jdbc.Driver";
url = "jdbc:jtds:sqlserver://127.0.0.1:1433/Northwind";
user = "sa";
pwd = "你的密码";
init();
}

public void init() {
try {
Class.forName(driver);
System.out.println("driver is ok");
con = DriverManager.getConnection(url, user, pwd);
System.out.println("conection is ok");
sta = con.createStatement();
rs = sta.executeQuery("select * from Categories");
while (rs.next())
System.out.println(rs.getString("CategoryName"));
} catch (Exception e) {
e.printStackTrace();
}
}

public static void main(String args [])
{
new Dbtest();
}
}




话题树型展开
人气 标题 作者 字数 发贴时间
6817 :-O求助 JSP中通过JDBC连接SQL SERVER 的问题 longchuan 504 2006-07-29 14:47
6336 Re::-O求助 JSP中通过JDBC连接SQL SERVER 的问题 sothis 144 2006-07-31 10:18
6253 Re::-O求助 JSP中通过JDBC连接SQL SERVER 的问题 why 166 2006-07-31 11:19
6903 Re::-O求助 JSP中通过JDBC连接SQL SERVER 的问题 longchuan 726 2006-08-06 22:08
6252 Re::-O求助 JSP中通过JDBC连接SQL SERVER 的问题 why 548 2006-08-07 10:21
6340 Re::-O求助 JSP中通过JDBC连接SQL SERVER 的问题 longchuan 15 2006-08-06 22:10
6306 Re::-O求助 JSP中通过JDBC连接SQL SERVER 的问题 longchuan 74 2006-08-07 12:42
6296 Re::-O求助 JSP中通过JDBC连接SQL SERVER 的问题 longchuan 29 2006-08-07 13:23
6350 Re::-O求助 JSP中通过JDBC连接SQL SERVER 的问题 wt_adam 1189 2006-08-07 15:20
6177 Re::-O求助 JSP中通过JDBC连接SQL SERVER 的问题 longchuan 21 2006-08-08 13:51
6162 Re::-O求助 JSP中通过JDBC连接SQL SERVER 的问题 longchuan 26 2006-08-09 12:12
6226 Re::-O求助 JSP中通过JDBC连接SQL SERVER 的问题 Novo 15 2006-08-09 20:51
6141 Re::-O求助 JSP中通过JDBC连接SQL SERVER 的问题 潇潇 30 2006-08-10 14:43
6158 Re::-O求助 JSP中通过JDBC连接SQL SERVER 的问题 潇潇 99 2006-08-10 14:45
6398 Re::-O求助 JSP中通过JDBC连接SQL SERVRE 的问题 longchuan 20 2006-07-29 19:43
6296 Re::-O求助 JSP中通过JDBC连接SQL SERVER 的问题 Novo 19 2006-08-10 22:57
6227 Re::-O求助 JSP中通过JDBC连接SQL SERVRE 的问题 chengbd 74 2006-07-30 01:19
6227 Re::-O求助 JSP中通过JDBC连接SQL SERVER 的问题 why 94 2006-07-30 22:38
6286 Re::-O求助 JSP中通过JDBC连接SQL SERVER 的问题 yjpwy 49 2006-07-31 17:10
6364 Re::-O求助 JSP中通过JDBC连接SQL SERVER 的问题 longchuan 2079 2006-08-01 14:29
6513 Re::-O求助 JSP中通过JDBC连接SQL SERVER 的问题 FireFox666 86 2006-08-04 22:10
6326 Re::-O求助 JSP中通过JDBC连接SQL SERVER 的问题 longchuan 21 2006-08-05 18:21
6207 Re::-O求助 JSP中通过JDBC连接SQL SERVER 的问题 why 711 2006-08-05 18:59

reply to postflat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923