SqlException

hi guys,

I am trying to use SqlServerDriver,i got an exception on which

i cant resolve.....

source code:

****************

import java.sql.*;

public class sqljdbc

{

public static void main(String[] args)

{

try

{

String url = "jdbc:microsoft:sqlserver://";

//String serverName = "localhost";

String serverName = "ow8";

String portNumber = "1433";

String databaseName = "sundar";

String userName = "sa";

String password = "sa";

String selectMethod = "cursor";

Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");

Connection conn = DriverManager.getConnection(url+serverName+":"+portNumber+";databaseName="+databaseName+";selectMethod="+selectMethod+";",userName,password);

Statement st=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);

ResultSet rs=st.executeQuery("select * from paging");

while(rs.next())

{

System.out.println(rs.getString(1));

}

}

catch (Exception e)

{

e.printStackTrace();

}

}

Exception that i got:

*********************

java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing 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 Source)

at com.microsoft.jdbc.base.BaseConnection.getNewImplConnection(Unknown Source)

at com.microsoft.jdbc.base.BaseConnection.open(Unknown Source)

at com.microsoft.jdbc.base.BaseDriver.connect(Unknown Source)

at java.sql.DriverManager.getConnection(DriverManager.java:525)

at java.sql.DriverManager.getConnection(DriverManager.java:171)

at sqljdbc.main(sqljdbc.java:17)

can anyone resolve this exception?

thanks in advance

[2171 byte] By [sundar82a] at [2007-11-27 1:57:17]
# 1

Hello There,

Error Estanblishing Socket, usually means your program cannot find or access the database specified.

Confirm you can ping the server name from your terminal, or use the ip address. also confirm if this is the right port number.

What Database? SQL Server 2000, or 2005?

Dob

dobsuna at 2007-7-12 1:32:42 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2
Check this topic http://forum.java.sun.com/thread.jspa?threadID=5163796&tstart=0Most likely your JDBC url is just wrong.
BalusCa at 2007-7-12 1:32:42 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 3
hi,I am using MsSqlServer2000,i am trying this code in localhost itself,i checked Tcp/Ip port number(1433) but still cant resolve that exception,any idea dude?
sundar82a at 2007-7-12 1:32:42 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...