关于Myeclipse连接sql server2000出错的问题
我安上了jdbc驱动,也在eclipse中加入了三个jar包。先打SP3,后又打的SP4。但运行以下连接代码,为什么会出现java.sql.SQLException:[M...
我安上了jdbc驱动,也在eclipse中加入了三个jar包。先打SP3,后又打的SP4。但运行以下连接代码,为什么会出现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:620)
at java.sql.DriverManager.getConnection(DriverManager.java:200)
at TestJDBC.main(TestJDBC.java:17)
123
代码如下:
import java.sql.*;
public class TestJDBC{
public static void main(String[] args) {
String DBDriver = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
java.sql.Connection conn = null;
ResultSet set = null;
Statement s = null;
try{
Class.forName(DBDriver);
conn = DriverManager.getConnection("jdbc:microsoft:sqlserver://127.0.0.1:1433;databaseName=pubs","sa","");
/*s = conn.createStatement();
set = s.executeQuery("select * from users");
while(set.next()){
System.out.print(set.getObject(1)+" ");
System.out.print(set.getObject(2)+" ");
System.out.print(set.getObject(3)+" ");
System.out.println();
}*/
}catch(Exception e){
e.printStackTrace();
}finally{
try{
if(s != null)
s.close();
}catch(Exception e){
}
try{
if(conn != null)
conn.close();
}catch(Exception e){
}
try{
if(set != null){
set.close();
}
}catch(Exception e){
}
}
System.out.println("123");
}
}
请高人指点,越详细越好,满意的话,我会加分的奥! 展开
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:620)
at java.sql.DriverManager.getConnection(DriverManager.java:200)
at TestJDBC.main(TestJDBC.java:17)
123
代码如下:
import java.sql.*;
public class TestJDBC{
public static void main(String[] args) {
String DBDriver = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
java.sql.Connection conn = null;
ResultSet set = null;
Statement s = null;
try{
Class.forName(DBDriver);
conn = DriverManager.getConnection("jdbc:microsoft:sqlserver://127.0.0.1:1433;databaseName=pubs","sa","");
/*s = conn.createStatement();
set = s.executeQuery("select * from users");
while(set.next()){
System.out.print(set.getObject(1)+" ");
System.out.print(set.getObject(2)+" ");
System.out.print(set.getObject(3)+" ");
System.out.println();
}*/
}catch(Exception e){
e.printStackTrace();
}finally{
try{
if(s != null)
s.close();
}catch(Exception e){
}
try{
if(conn != null)
conn.close();
}catch(Exception e){
}
try{
if(set != null){
set.close();
}
}catch(Exception e){
}
}
System.out.println("123");
}
}
请高人指点,越详细越好,满意的话,我会加分的奥! 展开
3个回答
展开全部
百度hi我。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
汗...在我的myeclipse中运行没报错...
1.可能是你在myeclipse中引入的包有问题
右击你的项目 -> properties -> java build path -> add external jars ->找到你的sqlserver驱动的三个包msbase.jar mssqlserver.jar msutil.jar-> 确定 ->运行
2.可能你的sqlserver端口号有问题 看看你的端口号是1433么
开始 -> microsoft sqlserver -> 服务器网络实用工具 -> 单机tcp/ip -> 属性
1.可能是你在myeclipse中引入的包有问题
右击你的项目 -> properties -> java build path -> add external jars ->找到你的sqlserver驱动的三个包msbase.jar mssqlserver.jar msutil.jar-> 确定 ->运行
2.可能你的sqlserver端口号有问题 看看你的端口号是1433么
开始 -> microsoft sqlserver -> 服务器网络实用工具 -> 单机tcp/ip -> 属性
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询