Topic: 还是连sqlserver的问题,请高手指教

  Print this page

1.还是连sqlserver的问题,请高手指教 Copy to clipboard
Posted by: netwalkerli
Posted on: 2004-10-21 21:25

code:
package test;
import java.sql.*;
public class Test{
public Test(){}
public static void main(String args[]){
try{
System.out.println("1");
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
System.out.println("1");
Connection conn=DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=pubs;User=sa;Password=123");

System.out.println("1");
Statement stmt=conn.createStatement();
System.out.println("1");
String sql="select * from web_account";
System.out.println("1");
ResultSet rs = stmt.executeQuery(sql);
System.out.println("1");
while(rs.next()) {
System.out.println("TestName:"+rs.getString("name"));
}
rs.close();
stmt.close();
conn.close();
} catch(Exception ex) { System.err.println(ex.getMessage()); }
}

}

结果是
1
1
[Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.

2.Re:还是连sqlserver的问题,请高手指教 [Re: netwalkerli] Copy to clipboard
Posted by: jameszhang
Posted on: 2004-10-21 21:30

网络问题吧

3.Re:还是连sqlserver的问题,请高手指教 [Re: netwalkerli] Copy to clipboard
Posted by: bill1
Posted on: 2004-10-22 11:43

检查sql server的服务器端口是否是1433

4.Re:还是连sqlserver的问题,请高手指教 [Re: netwalkerli] Copy to clipboard
Posted by: yy00_789
Posted on: 2004-10-22 14:21

将localhost换成数据库服务器的IP地址,如果是本机的话,写127.0.0.1,再试一下!

5.Re:还是连sqlserver的问题,请高手指教 [Re: netwalkerli] Copy to clipboard
Posted by: qq6600
Posted on: 2004-10-24 10:35

本地机有没网络防火墙,有的话关了在试,访问1433端口中,一般情况网络防火墙是不允许的。

6.Re:还是连sqlserver的问题,请高手指教 [Re: netwalkerli] Copy to clipboard
Posted by: k704790
Posted on: 2004-11-29 21:30

配置有问题,一定!

7.Re:还是连sqlserver的问题,请高手指教 [Re: netwalkerli] Copy to clipboard
Posted by: xhxasdf
Posted on: 2004-12-08 14:44

没有建立sqlserver的驱动,
你把驱动从倒入一次看看 !

8.Re:还是连sqlserver的问题,请高手指教 [Re: netwalkerli] Copy to clipboard
Posted by: ecsoftcn
Posted on: 2004-12-15 14:02

你的程序里面怎么没有倒入相关的包文件呢?
我看人家的代码上有:import com.microsoft.*;
你试一试~~~~~~~~`


   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