高分 java连接SQL server 2000 详细步骤
配置:winXP+JDK1.6+SQLserver2000出错信息:java.sql.SQLException:[Microsoft][SQLServer2000Driv...
配置:winXP+JDK1.6+SQL server 2000
出错信息:
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establis
hing 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 Sou
rce)
at com.microsoft.jdbc.base.BaseConnection.getNewImplConnection(Unknown S
ource)
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:549)
at java.sql.DriverManager.getConnection(DriverManager.java:181)
at MSDBdemo.main(MSDBdemo.java:11)
数据库连接失败
注:1,打过sp3,sp3a,sp4补丁
2,telnet 服务开启
3,JDBC驱动成功安装
4,防火墙关了
5,程序如下:
import java.sql.*;
public class SQLconn{
public static void main(String[] args){
try{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
System.out.println("数据库驱动程序注册成功!");
String url ="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=northwind";
String user = "sa";
String password = "";
Connection conn = DriverManager.getConnection(url, user, password);
System.out.println("数据库连接成功");
}
catch(Exception e)
{
e.printStackTrace();
System.out.println("数据库连接失败");
}
}
}
成功者再追加200分,决不食言,人格担保!
希望网上粘贴者不要浪费时间在这上面!
致:cd_zjs
感谢你的回答,但是新建时出错:“sa”已经存在!
诸位网友,请看清题目再回答好吗?
致:yizaijun
JSP的啊,大哥,复制前看一下好吗?
再声明一下:鄙人需要详细配置,不是代码哦~~ 展开
出错信息:
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establis
hing 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 Sou
rce)
at com.microsoft.jdbc.base.BaseConnection.getNewImplConnection(Unknown S
ource)
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:549)
at java.sql.DriverManager.getConnection(DriverManager.java:181)
at MSDBdemo.main(MSDBdemo.java:11)
数据库连接失败
注:1,打过sp3,sp3a,sp4补丁
2,telnet 服务开启
3,JDBC驱动成功安装
4,防火墙关了
5,程序如下:
import java.sql.*;
public class SQLconn{
public static void main(String[] args){
try{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
System.out.println("数据库驱动程序注册成功!");
String url ="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=northwind";
String user = "sa";
String password = "";
Connection conn = DriverManager.getConnection(url, user, password);
System.out.println("数据库连接成功");
}
catch(Exception e)
{
e.printStackTrace();
System.out.println("数据库连接失败");
}
}
}
成功者再追加200分,决不食言,人格担保!
希望网上粘贴者不要浪费时间在这上面!
致:cd_zjs
感谢你的回答,但是新建时出错:“sa”已经存在!
诸位网友,请看清题目再回答好吗?
致:yizaijun
JSP的啊,大哥,复制前看一下好吗?
再声明一下:鄙人需要详细配置,不是代码哦~~ 展开
9个回答
展开全部
import java.sql.*;
public class DatabaseConn {
private Connection conn;
private Statement stmt;
private String url =
"jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=northwind";
private String classforname = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
private String uid = "sa";
private String pwd = " ";
public DatabaseConn(){}
public Connection getConnection()
{
try{
Class.forName(classforname);
if (conn == null || conn.isClosed())
conn = DriverManager.getConnection( url, uid, pwd);
}catch (ClassNotFoundException ex){
ex.printStackTrace();
}catch (SQLException ex){
ex.printStackTrace();
}
return conn;
}
}
public class DatabaseConn {
private Connection conn;
private Statement stmt;
private String url =
"jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=northwind";
private String classforname = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
private String uid = "sa";
private String pwd = " ";
public DatabaseConn(){}
public Connection getConnection()
{
try{
Class.forName(classforname);
if (conn == null || conn.isClosed())
conn = DriverManager.getConnection( url, uid, pwd);
}catch (ClassNotFoundException ex){
ex.printStackTrace();
}catch (SQLException ex){
ex.printStackTrace();
}
return conn;
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
出现这样的提示:java.sql.SQLException 是网站问题
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
算了 自己写的不容易 还是留着自己用了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
高分 java连接SQL server 2000 详细步骤
悬赏分:200 - 离问题结束还有 14 天 22 小时
配置:winXP+JDK1.6+SQL server 2000
出错信息:
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establis
hing 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 Sou
rce)
at com.microsoft.jdbc.base.BaseConnection.getNewImplConnection(Unknown S
ource)
悬赏分:200 - 离问题结束还有 14 天 22 小时
配置:winXP+JDK1.6+SQL server 2000
出错信息:
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establis
hing 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 Sou
rce)
at com.microsoft.jdbc.base.BaseConnection.getNewImplConnection(Unknown S
ource)
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询