jQuery in Action, 3rd edition
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

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "MS Sql server2000 connection problem" Watch "MS Sql server2000 connection problem" New topic

MS Sql server2000 connection problem

aashini shah

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;

con = DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;databaseName=pubs","sa", "");
catch(SQLException e)
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
at com.microsoft.jdbc.base.BaseConnection.getNewImplConnection(Unknown S
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

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
Don't get me started about those stupid light bulbs.
subject: MS Sql server2000 connection problem
It's not a secret anymore!