This week's book / license giveaways are in the JDBC and Relational Databases and Java in General forums.
We're giving away four copies each of PostGIS in Action and Java Advanced Topics Training and have the authors on-line!
See this thread and this one for details.
The moose likes JDBC and Relational Databases and the fly likes MS Sql server2000 connection problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "MS Sql server2000 connection problem" Watch "MS Sql server2000 connection problem" New topic
Author

MS Sql server2000 connection problem

aashini shah
Greenhorn

Joined: Feb 06, 2008
Posts: 8
i have following code

import java.sql.*;
import java.*;

class Conn2
{
public static void main(String args[])throws Exception
{

Driver d=(Driver)Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
Connection con=null;
try
{

con = DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;databaseName=pubs","sa", "");
}
catch(SQLException e)
{
e.printStackTrace();
System.out.println(e.getMessage());
}
if(con!=null)
{
System.out.println("connection done");
}

}
}

I have installed driver for sql server2000 from http://www.microsoft.com/downloads/details.aspx?FamilyID=4f8f2f01-1ed7-4c4d-8f7b-3d47969e66ae&displaylang=en

and have also set classpath variable to msutil.jar,msbase.jar and mssqlserver.jar

Exception is coming :
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 Conn2.main(Conn2.java:14)
[Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.

wht should i do??
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Have you configured your SQL Server instance so you can connect to it? Namely: is it using SQL Server authentication (rather than Windows Integrated)? And have TCP/IP connections been enabled?

Also, is there a firewall between you and it? Is the server listening on 1433?

One more thing, why use the 2000 driver? Its bug-ridden and there are far better ones out there (MS have their own 2005 driver that works with 2000 & jTDS have an open source driver that is even better).


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: MS Sql server2000 connection problem