Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

somebody come in and help me check this error

 
lei zhang
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I installed SQL sever 2000 in my computer,but i doesn't connected it with the follow TestJDBC class:
---------------------------------------------------------------------------
import java.sql.*;


public class TestJDBC{
public static void main(String[] args){
try {

String url =
"jdbc:microsoft:sqlserver://localhost:1433;databaseName=jiaotong";
String username = "java";
String password = "java";
Connection conn = null;
System.out.println("1");
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
System.out.println("2");
conn = DriverManager.getConnection(url, username, password);
System.out.println("2" + conn);
Statement stmt = conn.createStatement() ;
//String strSql = " insert into cat values('1','jdbc','m',0) " ;
// stmt.execute( strSql );

stmt.close();
conn.close();

}
catch (Exception e) {
e.printStackTrace();
}

}
}
--------------------------------------------------------------------------
and the errors are follow:
D:\>java TestJDBC
1
2
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(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at TestJDBC.main(TestJDBC.java:18)

D:\>
-------------------------------------------------------------------------
set sql_home=D:\sql
set CLASSPATH=%classpath%;%sql_home%\mssqlserver.jar;%sql_home%\msutil.jar;%sql_home%\msbase.jar;

plase give me a help, thanks
 
praveen kanakarajan
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
pls visit the link may be it will help you
http://support.microsoft.com/default.aspx?scid=kb;en-us;313178
 
lei zhang
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you praveen k










jack
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic