JDBC 连接SQLServer 的错误!请高手解答!

bbshero 2003-10-09 03:42:28
jbuider7+sqlserver2000中
语句:connect = DriverManager.getConnection(url,db_user,db_pwd);
报告说:
EmbededTomcat: Startup time 2013

2003-10-09 15:08:45 - Ctx() : Compiling: /Jsp1.jsp to Jsp1_2

2003-10-09 15:08:49 - SessionIdGenerator: Created random class java.security.SecureRandom

sm.db.sqlserver.connect FAILURE [Microsoft][SQLServer JDBC Driver]Error establishing socket.
...全文
65 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
YuLimin 2003-10-09
  • 打赏
  • 举报
回复
2. Registering the Driver
Registering the driver tells the JDBC driver manager which driver to load. When loading a driver using class.forName(), you must specify the name of the driver:

com.microsoft.jdbc.sqlserver.SQLServerDriver

For example:

Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");

3. Passing the Connection URL
After registering the driver, you must pass your database connection information in the form of a connection URL. The following is a template URL for the SQL Server 2000 Driver for JDBC. Substitute the values specific to your database. (For instructions on connecting to named instances, see "Connecting to Named Instances" in the SQL Server 2000 Driver for JDBC topic.)

jdbc:microsoft:sqlserver://server_name:1433

For example, to specify a connection URL that includes the user ID "username" and the password "secret":

Connection conn = DriverManager.getConnection
("jdbc:microsoft:sqlserver://server1:1433","username","secret");

NOTES:

The server_name is an IP address or a host name, assuming that your network resolves host names to IP addresses. You can test this by using the ping command to access the host name and verifying that you receive a reply with the correct IP address.

The numeric value after the server name is the port number on which the database is listening. The values listed here are sample defaults. You should determine the port number that your database is using and substitute that value.

You can find the complete list of Connection URL parameters in "Connection String Properties" for the SQL Server 2000 Driver for JDBC.
lingaiguo 2003-10-09
  • 打赏
  • 举报
回复
connect = DriverManager.getConnection(url;DatabaseName=pubs;db_user;db_pwd);
应该这样才行~~~

81,090

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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