JBuilder中如何用SQL Server2000 Driver 连接数据库?

polarstar720 2007-05-21 09:20:45
高手指导:
我开发了一个应用程序,需要连接数据库,可是不知道如何下手,望高手详细指点!如何连接驱动?要设置什么?
...全文
425 12 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
锄头杨 2008-05-07
  • 打赏
  • 举报
回复
你可鞥没有驱动啊 啊
可以去微软下砸
northenwolf1 2007-06-26
  • 打赏
  • 举报
回复
楼上说的对,照做吧,没有问题!
t_ianya 2007-05-26
  • 打赏
  • 举报
回复
把你的驱动加载到工程里:
1;在Tools-->configure-->libraries中单击user_home,
点击左下方的“new”新建一个文件夹“SQLServer”,
然后选中它,点右边的“class”选项,单击“add”
把jdbc的lib下的mssqlserver.jar,msutil.jar,msbase.jar添加进来
然后"ok"
2:选择project-->project properties-->path
在右边的选项选择"required libraries",点"add",把刚才所建立
的SQLServer这个包添加进来,“ok”
试一试
dasong2410 2007-05-25
  • 打赏
  • 举报
回复
JDBC、SP4
polarstar720 2007-05-23
  • 打赏
  • 举报
回复

tdy1234() :
我程序里面有这样一段代码,上面的错误结果是我在测试数据库连接的时候出现的错误.
而我在运行程序的时候,会这样报错:
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.
at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
at com.microsoft.jdbc.sqlserver.tds.TDSConnection.<init>(Unknown Source)
at com.microsoft.jdbc.sqlserver.SQLServerImplConnection.open(Unknown Source)
at com.microsoft.jdbc.base.BaseConnection.getNewImplConnection(Unknown Source)
at com.microsoft.jdbc.base.BaseConnection.open(Unknown Source)
at com.microsoft.jdbc.base.BaseDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(DriverManager.java:512)
at java.sql.DriverManager.getConnection(DriverManager.java:193)
at com.csbook.restaurant.utility.CheckUser.isValidUser(CheckUser.java:36)
at com.csbook.restaurant.LoginSystem.login_actionPerformed(LoginSystem.java:77)
at com.csbook.restaurant.ActionListener.actionPerformed(LoginSystem.java:121)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1764)
at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1817)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:419)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:257)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:245)
at java.awt.Component.processMouseEvent(Component.java:5134)
at java.awt.Component.processEvent(Component.java:4931)
at java.awt.Container.processEvent(Container.java:1566)
at java.awt.Component.dispatchEventImpl(Component.java:3639)
at java.awt.Container.dispatchEventImpl(Container.java:1623)
at java.awt.Component.dispatchEvent(Component.java:3480)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3450)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3165)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3095)
at java.awt.Container.dispatchEventImpl(Container.java:1609)
at java.awt.Window.dispatchEventImpl(Window.java:1590)
at java.awt.Component.dispatchEvent(Component.java:3480)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:450)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:197)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:144)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:136)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)


zhizhi02 2007-05-23
  • 打赏
  • 举报
回复
打补丁sql sp4
sikezxlovelovecjl 2007-05-22
  • 打赏
  • 举报
回复
你可以有两种方式连接,一种是用1433端口连接,也就是上面的那种连接,不过要打开1433端口以及导入3个包!另一种就是用数据源连接:
String driverName = "sun.jdbc.odbc.JdbcOdbcDriver";//引号里放驱动的名称,
String connectionString = "jdbc:odbc:你的数据源名字";//这里放数据库路径,
try {

Class.forName(driverName);//这里在程序中加载类
DriverManager.getConnection(
connectionString);//连接
}
catch (ClassNotFoundException e) {
System.err.println("DB driver not fount");
}
tdy1234 2007-05-22
  • 打赏
  • 举报
回复
这样就连上了
tdy1234 2007-05-22
  • 打赏
  • 举报
回复
你先在运行环境里面添加一个SQLSEVER 的驱动
这个错误就是说没有驱动呀 驱动SQLSEVER盘里面应该自带的
然后是这样一段代码
String driverName = "com.microsoft.jdbc.sqlserver.SQLServerDriver";//引号里放驱动的名称,
String connectionString = "";//这里放数据库路径,
String userName = "produsr";//数据库角色名称
String password = "123456";//数据库密码

try {

Class.forName(driverName);//这里在程序中加载类
retval = DriverManager.getConnection(
connectionString, userName, password);//连接
}
catch (ClassNotFoundException e) {
System.err.println("DB driver not fount");
}
polarstar720 2007-05-21
  • 打赏
  • 举报
回复
错误结果显示:
The driver:com.microsoft.SQLServerDriver could not be loaded.This could be a problem with the driver itself,or that the driver is not found on the classpath.


现在怎么办啊 ?

51,397

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧