| Author |
SQL Server 2005 Connectivity issues
|
Rohan Pujari
Greenhorn
Joined: Feb 27, 2007
Posts: 24
|
|
I have java version j2sdk1.4.2_13 installed in C:\j2sdk1.4.2_13 and SQL Server 2005 . I downloaded the JDBC driver version 1.0 from Microsoft website and extracted the contents in C:\Temp. Now will compiling the DataConnect (a simple java connectivity code straight from micro API) i get the following error "DataConnect.java:12: unreported exception java.lang.ClassNotFoundException; must be caught or declared to be thrown Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");" .I set the classpath also using the following command set CLASSPATH=.;C:\Temp\sqljdbc_1.0\enu\sqljdbc.jar still the same error please help The jdbc connectivity code is
|
 |
Paul Sturrock
Bartender
Joined: Apr 14, 2004
Posts: 10336
|
|
Have you tried doing what the compiler message is telling you to do? Class.forName() throws a ClassNotFoundException, which is a checked exception so you are going to have to handle it in your code. [ March 19, 2007: Message edited by: Paul Sturrock ]
|
JavaRanch FAQ HowToAskQuestionsOnJavaRanch
|
 |
Rohan Pujari
Greenhorn
Joined: Feb 27, 2007
Posts: 24
|
|
i have handled that exception but now it is giving me a new error com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the ho st has failed. java.net.ConnectException: Connection refused: connect at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(U nknown Source) at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(Unknown Sour ce) at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(Unknown Source) at java.sql.DriverManager.getConnection(DriverManager.java:512) at java.sql.DriverManager.getConnection(DriverManager.java:193) at DataConnect.<init>(DataConnect.java:14) at DataConnect.main(DataConnect.java:31)
|
 |
Paul Sturrock
Bartender
Joined: Apr 14, 2004
Posts: 10336
|
|
Good, progress! You need to work out why the connection is being refused. The most likely possibility is that SQL Server 2005, unlike 2000, doesn't have TCP/IP enabled out the box. So I'd start by making sure you have configured your server to accept TCP/IP traffic. [ March 19, 2007: Message edited by: Paul Sturrock ]
|
 |
Rohan Pujari
Greenhorn
Joined: Feb 27, 2007
Posts: 24
|
|
|
yep i started the TCP/IP port but now it says the login has failed for the user. now i guess i have to configure the login part in sql server since i generally login through the windows login. thanks for your help Paul i really appreciate it.
|
 |
Paul Sturrock
Bartender
Joined: Apr 14, 2004
Posts: 10336
|
|
You can use Windows integrated authentication with JDBC, but you will need to change the driver you use, since Microsoft's own driver doesn't yet support it. jTDS supports NTLM, as (I think) does DataDirect (though unfortunately their driver is not free). If you want to continue using Microsoft's own JDBC driver you will need to use SQL Server authentication.
|
 |
Rohan Pujari
Greenhorn
Joined: Feb 27, 2007
Posts: 24
|
|
Finally i am able to connect to the database using the jtds. Still had some SSO error but included a dll file in the path and finally am able to connect to the database without any error. Thanks Paul for helping me out with this. Thanks a lot. Javaranch is really a great website
|
 |
 |
|
|
subject: SQL Server 2005 Connectivity issues
|
|
|