f



MS SQL Server 2000 and MS JDBC SQL Server driver problems. (Connection timed out, followed by Error establishing socket)

I have downloaded the MS SQL Server 2000 Enterprise Evaluation edition, and
the MS SQL 2000 Server JDBC driver.

I have installed and configured the MS SQL Server 2000 onto two computers,
which reside on the same network.  (In fact, these two computers comprise
the entire network).

The network server (computer name=SUNCDS1), and the lone node (SUNCDS2),
each have their own SQL Server 2000 instance.

The SQL Server 2000 Enterprise Manager console on SUNCDS1 shows both SQL
Server instances, the (local) instance, which is SUNCDS1, and also SUNCDS2.
It may be worthwhile to mention that the SUNCDS2 instance on the Enterprise
console does not show the SQL Server Agent as being started, but I can
navigate to the SUNCDS2 databases, and display the table information.  If I
try to start the SQL Server Agent for SUNCDS2, I receive the message "Access
is Denied".  The enterprise console on the SUNCDS2 machine indeed shows the
SQL Server Agent as being started.

I have written a sample Java application that uses both the MS SQL Server
ODBC driver and a JDBC type 4 driver (MS SQL Server 2000 JDBC) to establish
a connection to the SUNCDS2 instance.  This application resides on the
SUNCDS1 network server.  The ODBC driver will connect to SUNCDS2 instance
wihout a problem.

The JDBC driver does not connect to SUNCDS2.  The JDBC driver will, however,
connect to the local SQL Server instance that resides on SUNCDS1.

Following are the code snippet to establish the JDBC driver connection, and
also the DriverManager logging messages that show the failure.  (I have also
included the messages regarding the successful ODBC connection to SUNCDS2 at
the end of this post, for what it's worth).

static void testJDBCConnection()
 {
    System.out.println("testing JDBC connection type 4");
 Driver d = null;
 DriverManager.println("===================== testing JDBC connection type 4
=====================");

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

  Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
  } catch (InstantiationException e) {e.printStackTrace();}
    catch (IllegalAccessException e) {e.printStackTrace();}
    catch (ClassNotFoundException e) {
         e.printStackTrace();}
    try
    {
        String url =
"jdbc:microsoft:sqlserver://SUNCDS2:1433;databaseName=master";
        System.out.println(url);
        System.out.println(d);
        Connection conn = DriverManager.getConnection(url, "sa", "scd123");
        DatabaseMetaData dma = conn.getMetaData ();
  System.out.println("\nConnected to " + dma.getURL());
  System.out.println("Driver       " +    dma.getDriverName());
  System.out.println("Version      " +   dma.getDriverVersion());
  System.out.println("");
  conn.close();

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


===================== testing JDBC connection type 4 =====================
 registerDriver:
driver[className=com.microsoft.jdbc.sqlserver.SQLServerDriver,com.microsoft.jdbc.sqlserver.SQLServerDriver@7a1576]
 DriverManager.getConnection("jdbc:microsoft:sqlserver://SUNCDS2:1433;databaseName=master")    tryingdriver[className=sun.jdbc.odbc.JdbcOdbcDriver,sun.jdbc.odbc.JdbcOdbcDriver@1f06dc3] *Driver.connect(jdbc:microsoft:sqlserver://SUNCDS2:1433;databaseName=master)    tryingdriver[className=com.microsoft.jdbc.sqlserver.SQLServerDriver,com.microsoft.jdbc.sqlserver.SQLServerDriver@7a1576] Connection.finalize sun.jdbc.odbc.JdbcOdbcConnection@79e304 *Connection.close 0 Statement(s) to close ResultSet.finalize sun.jdbc.odbc.JdbcOdbcResultSet@273686 java.sql.SQLException: [Microsoft][SQLServer 2000 Driver forJDBC]Connectiontimed out: connect at com.microsoft.jdbc.base.BaseExceptions.createException(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(UnknownSource) at com.microsoft.jdbc.base.BaseConnection.getNewImplConnection(UnknownSource) 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:512) at java.sql.DriverManager.getConnection(DriverManager.java:171) at SQLConnection.testJDBCConnection(SQLConnection.java:228) at SQLConnection.getDBConnection(SQLConnection.java:117) at SQLConnection.test(SQLConnection.java:22) at SQLConnection$1.actionPerformed(SQLConnection.java:66) at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1786) atjavax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1839) atjavax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420) at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258) atjavax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:245) at java.awt.Component.processMouseEvent(Component.java:5100) at java.awt.Component.processEvent(Component.java:4897) at java.awt.Container.processEvent(Container.java:1569) at java.awt.Component.dispatchEventImpl(Component.java:3615) at java.awt.Container.dispatchEventImpl(Container.java:1627) at java.awt.Component.dispatchEvent(Component.java:3477) at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3483) at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3198) at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3128) at java.awt.Container.dispatchEventImpl(Container.java:1613) at java.awt.Window.dispatchEventImpl(Window.java:1606) at java.awt.Component.dispatchEvent(Component.java:3477) at java.awt.EventQueue.dispatchEvent(EventQueue.java:456) atjava.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201) atjava.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137) at java.awt.EventDispatchThread.run(EventDispatchThread.java:100) SQLException: SQLState(HY000) java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Errorestablishing 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(UnknownSource) at com.microsoft.jdbc.base.BaseConnection.getNewImplConnection(UnknownSource) 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:512) at java.sql.DriverManager.getConnection(DriverManager.java:171) at SQLConnection.testJDBCConnection(SQLConnection.java:228) at SQLConnection.getDBConnection(SQLConnection.java:117) at SQLConnection.test(SQLConnection.java:22) at SQLConnection$1.actionPerformed(SQLConnection.java:66) at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1786) atjavax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1839) atjavax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420) at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258) atjavax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:245) at java.awt.Component.processMouseEvent(Component.java:5100) at java.awt.Component.processEvent(Component.java:4897) at java.awt.Container.processEvent(Container.java:1569) at java.awt.Component.dispatchEventImpl(Component.java:3615) at java.awt.Container.dispatchEventImpl(Container.java:1627) at java.awt.Component.dispatchEvent(Component.java:3477) at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3483) at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3198) at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3128) at java.awt.Container.dispatchEventImpl(Container.java:1613) at java.awt.Window.dispatchEventImpl(Window.java:1606) at java.awt.Component.dispatchEvent(Component.java:3477) at java.awt.EventQueue.dispatchEvent(EventQueue.java:456) atjava.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201) atjava.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137) at java.awt.EventDispatchThread.run(EventDispatchThread.java:100) SQLException: SQLState(08001) getConnection failed: java.sql.SQLException: [Microsoft][SQLServer 2000Driver for JDBC]Error establishing socket. :===================== testing ODBC connection ===================== DriverManager.getConnection("jdbc:odbc:Driver={SQLServer};Server=SUNCDS2;Database=master;UID=sa; PWD=scd123")    tryingdriver[className=sun.jdbc.odbc.JdbcOdbcDriver,sun.jdbc.odbc.JdbcOdbcDriver@1f06dc3] *Driver.connect (jdbc:odbc:Driver={SQLServer};Server=SUNCDS2;Database=master;UID=sa; PWD=scd123) JDBC to ODBC Bridge: Checking security No SecurityManager present, assuming trusted application/applet Allocating Environment handle (SQLAllocEnv) hEnv=51647136 Allocating Connection handle (SQLAllocConnect) hDbc=51647304 Connecting (SQLDriverConnect), hDbc=51647304, szConnStrIn=Driver={SQLServer};Server=SUNCDS2;Database=master;UID=sa; PWD=scd123 RETCODE = 1 WARNING - Generating SQLWarning... SQLWarning: reason([Microsoft][ODBC SQL Server Driver][SQL Server]Changeddatabase context to 'master'.) SQLstate(01000) vendor code(5701) SQLWarning: reason([Microsoft][ODBC SQL Server Driver][SQL Server]Changedlanguage setting to us_english.) SQLstate(01000) vendor code(5703) *Connection.getMetaData *DatabaseMetaData.getDriverName Get connection info string (SQLGetInfo), hDbc=51647304, fInfoType=6,len=300 SQLSRV32.DLL *DatabaseMetaData.getDriverVersion Get connection info string (SQLGetInfo), hDbc=51647304, fInfoType=7,len=300 03.85.1117 *DatabaseMetaData.getDriverName Get connection info string (SQLGetInfo), hDbc=51647304, fInfoType=6,len=300 SQLSRV32.DLL Driver name:    JDBC-ODBC Bridge (SQLSRV32.DLL) *DatabaseMetaData.getDriverVersion Get connection info string (SQLGetInfo), hDbc=51647304, fInfoType=7,len=300 03.85.1117 Driver version: 2.0001 (03.85.1117) Caching SQL type information *Connection.getMetaData *DatabaseMetaData.getTypeInfo Allocating Statement Handle (SQLAllocStmt), hDbc=51647304 hStmt=51650696 Get type info (SQLGetTypeInfo), hStmt=51650696, fSqlType=0 Number of result columns (SQLNumResultCols), hStmt=51650696 value=20 Get connection info string (SQLGetInfo), hDbc=51647304, fInfoType=10,len=300 03.52.0000 Fetching (SQLFetch), hStmt=51650696 Column attributes (SQLColAttributes), hStmt=51650696, icol=1, type=2 value (int)=-9 Column attributes (SQLColAttributes), hStmt=51650696, icol=1, type=3 value (int)=256 Get string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 sql_variant Get integer data (SQLGetData), hStmt=51650696, column=2 value=-150 Get integer data (SQLGetData), hStmt=51650696, column=3 value=8000 Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 uniqueidentifier Get integer data (SQLGetData), hStmt=51650696, column=2 value=-11 Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 ntext Get integer data (SQLGetData), hStmt=51650696, column=2 value=-10 Get integer data (SQLGetData), hStmt=51650696, column=3 value=1073741823 Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 nvarchar Get integer data (SQLGetData), hStmt=51650696, column=2 value=-9 Get integer data (SQLGetData), hStmt=51650696, column=3 value=4000 Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 sysname Get integer data (SQLGetData), hStmt=51650696, column=2 value=-9 Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 nchar Get integer data (SQLGetData), hStmt=51650696, column=2 ResultSet.finalize sun.jdbc.odbc.JdbcOdbcResultSet@30d82d Connection.finalize sun.jdbc.odbc.JdbcOdbcConnection@c09554 *Connection.close 0 Statement(s) to close ResultSet.finalize sun.jdbc.odbc.JdbcOdbcResultSet@18bf072 value=-8 Get integer data (SQLGetData), hStmt=51650696, column=3 value=4000 Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 bit Get integer data (SQLGetData), hStmt=51650696, column=2 value=-7 Get integer data (SQLGetData), hStmt=51650696, column=3 value=1 Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 tinyint Get integer data (SQLGetData), hStmt=51650696, column=2 value=-6 Get integer data (SQLGetData), hStmt=51650696, column=3 value=3 Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 tinyint identity Get integer data (SQLGetData), hStmt=51650696, column=2 value=-6 Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 bigint Get integer data (SQLGetData), hStmt=51650696, column=2 value=-5 Get integer data (SQLGetData), hStmt=51650696, column=3 value=19 Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 bigint identity Get integer data (SQLGetData), hStmt=51650696, column=2 value=-5 Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 image Get integer data (SQLGetData), hStmt=51650696, column=2 value=-4 Get integer data (SQLGetData), hStmt=51650696, column=3 value=2147483647 Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 varbinary Get integer data (SQLGetData), hStmt=51650696, column=2 value=-3 Get integer data (SQLGetData), hStmt=51650696, column=3 value=8000 Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 binary Get integer data (SQLGetData), hStmt=51650696, column=2 value=-2 Get integer data (SQLGetData), hStmt=51650696, column=3 value=8000 Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 timestamp Get integer data (SQLGetData), hStmt=51650696, column=2 value=-2 Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 text Get integer data (SQLGetData), hStmt=51650696, column=2 value=-1 Get integer data (SQLGetData), hStmt=51650696, column=3 value=2147483647 Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 char Get integer data (SQLGetData), hStmt=51650696, column=2 value=1 Get integer data (SQLGetData), hStmt=51650696, column=3 value=8000 Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 numeric Get integer data (SQLGetData), hStmt=51650696, column=2 value=2 Get integer data (SQLGetData), hStmt=51650696, column=3 value=38 Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 numeric() identity Get integer data (SQLGetData), hStmt=51650696, column=2 value=2 Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 decimal Get integer data (SQLGetData), hStmt=51650696, column=2 value=3 Get integer data (SQLGetData), hStmt=51650696, column=3 value=38 Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 money Get integer data (SQLGetData), hStmt=51650696, column=2 value=3 Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 smallmoney Get integer data (SQLGetData), hStmt=51650696, column=2 value=3 Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 decimal() identity Get integer data (SQLGetData), hStmt=51650696, column=2 value=3 Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 int Get integer data (SQLGetData), hStmt=51650696, column=2 value=4 Get integer data (SQLGetData), hStmt=51650696, column=3 value=10 Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 int identity Get integer data (SQLGetData), hStmt=51650696, column=2 value=4 Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 smallint Get integer data (SQLGetData), hStmt=51650696, column=2 value=5 Get integer data (SQLGetData), hStmt=51650696, column=3 value=5 Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 smallint identity Get integer data (SQLGetData), hStmt=51650696, column=2 value=5 Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 float Get integer data (SQLGetData), hStmt=51650696, column=2 value=6 Get integer data (SQLGetData), hStmt=51650696, column=3 value=15 Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 real Get integer data (SQLGetData), hStmt=51650696, column=2 value=7 Get integer data (SQLGetData), hStmt=51650696, column=3 value=7 Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 datetime Get integer data (SQLGetData), hStmt=51650696, column=2 value=11 Get integer data (SQLGetData), hStmt=51650696, column=3 value=23 Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 smalldatetime Get integer data (SQLGetData), hStmt=51650696, column=2 value=11 Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 varchar Get integer data (SQLGetData), hStmt=51650696, column=2 value=12 Get integer data (SQLGetData), hStmt=51650696, column=3 value=8000 Fetching (SQLFetch), hStmt=51650696 End of result set (SQL_NO_DATA) *ResultSet.close Free statement (SQLFreeStmt), hStmt=51650696, fOption=1 *ResultSet has been closed Get connection info (SQLGetInfo), hDbc=51647304, fInfoType=44 int value=23 Get connection info (SQLGetInfo), hDbc=51647304, fInfoType=168 int value=8065 Get connection info (SQLGetInfo), hDbc=51647304, fInfoType=151 int value=73695 Get connection info (SQLGetInfo), hDbc=51647304, fInfoType=145 int value=69599 Get connection info (SQLGetInfo), hDbc=51647304, fInfoType=121 int value=15 Get connection info (SQLGetInfo), hDbc=51647304, fInfoType=120 int value=2 Get connection info (SQLGetInfo), hDbc=51647304, fInfoType=153 int value=1 getConnection returningdriver[className=sun.jdbc.odbc.JdbcOdbcDriver,sun.jdbc.odbc.JdbcOdbcDriver@1f06dc3] *Connection.getMetaData *DatabaseMetaData.getURL *DatabaseMetaData.getDriverName Get connection info string (SQLGetInfo), hDbc=51647304, fInfoType=6,len=300 SQLSRV32.DLL *DatabaseMetaData.getDriverVersion Get connection info string (SQLGetInfo), hDbc=51647304, fInfoType=7,len=300 03.85.1117 *Connection.close 0 Statement(s) to close Disconnecting (SQLDisconnect), hDbc=51647304 Closing connection (SQLFreeConnect), hDbc=51647304 Closing environment (SQLFreeEnv), hEnv=51647136

0
Stuart
1/2/2005 6:08:50 PM
comp.lang.java.databases 3049 articles. 0 followers. samyaksulabh (16) is leader. Post Follow

4 Replies
1816 Views

Similar Articles

[PageSpeed] 48

Hi. In order for the jdbc driver to connect to the DBMS, the DBMS needs to be
configured to listen for TCP connection requests. It does not do this by default.
Ie: "Mixed mode" connections in setup. 1433 is the default port for a SQLServer
to use for tcp connections. You should verify that the DBMS is using that port...
Joe Weinstein at BEA

Stuart Leonard wrote:

> I have downloaded the MS SQL Server 2000 Enterprise Evaluation edition, and
> the MS SQL 2000 Server JDBC driver.
> 
> I have installed and configured the MS SQL Server 2000 onto two computers,
> which reside on the same network.  (In fact, these two computers comprise
> the entire network).
> 
> The network server (computer name=SUNCDS1), and the lone node (SUNCDS2),
> each have their own SQL Server 2000 instance.
> 
> The SQL Server 2000 Enterprise Manager console on SUNCDS1 shows both SQL
> Server instances, the (local) instance, which is SUNCDS1, and also SUNCDS2.
> It may be worthwhile to mention that the SUNCDS2 instance on the Enterprise
> console does not show the SQL Server Agent as being started, but I can
> navigate to the SUNCDS2 databases, and display the table information.  If I
> try to start the SQL Server Agent for SUNCDS2, I receive the message "Access
> is Denied".  The enterprise console on the SUNCDS2 machine indeed shows the
> SQL Server Agent as being started.
> 
> I have written a sample Java application that uses both the MS SQL Server
> ODBC driver and a JDBC type 4 driver (MS SQL Server 2000 JDBC) to establish
> a connection to the SUNCDS2 instance.  This application resides on the
> SUNCDS1 network server.  The ODBC driver will connect to SUNCDS2 instance
> wihout a problem.
> 
> The JDBC driver does not connect to SUNCDS2.  The JDBC driver will, however,
> connect to the local SQL Server instance that resides on SUNCDS1.
> 
> Following are the code snippet to establish the JDBC driver connection, and
> also the DriverManager logging messages that show the failure.  (I have also
> included the messages regarding the successful ODBC connection to SUNCDS2 at
> the end of this post, for what it's worth).
> 
> static void testJDBCConnection()
>  {
>     System.out.println("testing JDBC connection type 4");
>  Driver d = null;
>  DriverManager.println("===================== testing JDBC connection type 4
> =====================");
> 
>  try {
>   d =
> (Driver)Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
> 
>   Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
>   } catch (InstantiationException e) {e.printStackTrace();}
>     catch (IllegalAccessException e) {e.printStackTrace();}
>     catch (ClassNotFoundException e) {
>          e.printStackTrace();}
>     try
>     {
>         String url =
> "jdbc:microsoft:sqlserver://SUNCDS2:1433;databaseName=master";
>         System.out.println(url);
>         System.out.println(d);
>         Connection conn = DriverManager.getConnection(url, "sa", "scd123");
>         DatabaseMetaData dma = conn.getMetaData ();
>   System.out.println("\nConnected to " + dma.getURL());
>   System.out.println("Driver       " +    dma.getDriverName());
>   System.out.println("Version      " +   dma.getDriverVersion());
>   System.out.println("");
>   conn.close();
> 
>     }
>     catch (SQLException e) {e.printStackTrace();}
>  }
> 
> 
> ===================== testing JDBC connection type 4 =====================
>  registerDriver:
> driver[className=com.microsoft.jdbc.sqlserver.SQLServerDriver,com.microsoft.jdbc.sqlserver.SQLServerDriver@7a1576]
>  DriverManager.getConnection("jdbc:microsoft:sqlserver://SUNCDS2:1433;databaseName=master")    tryingdriver[className=sun.jdbc.odbc.JdbcOdbcDriver,sun.jdbc.odbc.JdbcOdbcDriver@1f06dc3] *Driver.connect(jdbc:microsoft:sqlserver://SUNCDS2:1433;databaseName=master)    tryingdriver[className=com.microsoft.jdbc.sqlserver.SQLServerDriver,com.microsoft.jdbc.sqlserver.SQLServerDriver@7a1576] Connection.finalize sun.jdbc.odbc.JdbcOdbcConnection@79e304 *Connection.close 0 Statement(s) to close ResultSet.finalize sun.jdbc.odbc.JdbcOdbcResultSet@273686 java.sql.SQLException: [Microsoft][SQLServer 2000 Driver forJDBC]Connectiontimed out: connect at com.microsoft.jdbc.base.BaseExceptions.createException(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(UnknownSource) at com.microsoft.jdbc.base.BaseConnection.getNewImplC
onnection(UnknownSource) 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:512) at java.sql.DriverManager.getConnection(DriverManager.java:171) at SQLConnection.testJDBCConnection(SQLConnection.java:228) at SQLConnection.getDBConnection(SQLConnection.java:117) at SQLConnection.test(SQLConnection.java:22) at SQLConnection$1.actionPerformed(SQLConnection.java:66) at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1786) atjavax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1839) atjavax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel..java:420) at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258) atjavax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:245) at java.awt.Component.processMouseEvent(Component.java:5100) at java.awt.Compone
nt.processEvent(Component.java:4897) at java.awt.Container.processEvent(Container.java:1569) at java.awt.Component.dispatchEventImpl(Component.java:3615) at java.awt.Container.dispatchEventImpl(Container.java:1627) at java.awt.Component.dispatchEvent(Component.java:3477) at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3483) at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3198) at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3128) at java.awt.Container.dispatchEventImpl(Container.java:1613) at java.awt.Window.dispatchEventImpl(Window.java:1606) at java.awt.Component.dispatchEvent(Component.java:3477) at java.awt.EventQueue.dispatchEvent(EventQueue.java:456) atjava.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201) atjava.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145) at java.awt.EventDispatchThr
ead.pumpEvents(EventDispatchThread.java:137) at java.awt.EventDispatchThread.run(EventDispatchThread.java:100) SQLException: SQLState(HY000) java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Errorestablishing 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(UnknownSource) at com.microsoft.jdbc.base.BaseConnection.getNewImplConnection(UnknownSource) 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:512) at java.sql.DriverManager.getConnection(DriverManager.java:171) at SQLConnection.testJDBCConnection(SQLConnection.java:228) a
t SQLConnection.getDBConnection(SQLConnection.java:117) at SQLConnection.test(SQLConnection.java:22) at SQLConnection$1.actionPerformed(SQLConnection.java:66) at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1786) atjavax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1839) atjavax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420) at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258) atjavax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:245) at java.awt.Component.processMouseEvent(Component.java:5100) at java.awt.Component.processEvent(Component.java:4897) at java.awt.Container.processEvent(Container.java:1569) at java.awt.Component.dispatchEventImpl(Component.java:3615) at java.awt.Container.dispatchEventImpl(Container.java:1627) at java.awt.Component.dispatchEvent(Component.java:3477) at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java
:3483) at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3198) at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3128) at java.awt.Container.dispatchEventImpl(Container.java:1613) at java.awt.Window.dispatchEventImpl(Window.java:1606) at java.awt.Component.dispatchEvent(Component.java:3477) at java.awt.EventQueue.dispatchEvent(EventQueue.java:456) atjava.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201) atjava.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137) at java.awt.EventDispatchThread.run(EventDispatchThread.java:100) SQLException: SQLState(08001) getConnection failed: java.sql.SQLException: [Microsoft][SQLServer 2000Driver for JDBC]Error establishing socket. :===================== testing ODBC connection ===================== DriverManager.g
etConnection("jdbc:odbc:Driver={SQLServer};Server=SUNCDS2;Database=master;UID=sa; PWD=scd123")    tryingdriver[className=sun.jdbc.odbc.JdbcOdbcDriver,sun.jdbc.odbc.JdbcOdbcDriver@1f06dc3] *Driver.connect (jdbc:odbc:Driver={SQLServer};Server=SUNCDS2;Database=master;UID=sa; PWD=scd123) JDBC to ODBC Bridge: Checking security No SecurityManager present, assuming trusted application/applet Allocating Environment handle (SQLAllocEnv) hEnv=51647136 Allocating Connection handle (SQLAllocConnect) hDbc=51647304 Connecting (SQLDriverConnect), hDbc=51647304, szConnStrIn=Driver={SQLServer};Server=SUNCDS2;Database=master;UID=sa; PWD=scd123 RETCODE = 1 WARNING - Generating SQLWarning... SQLWarning: reason([Microsoft][ODBC SQL Server Driver][SQL Server]Changeddatabase context to 'master'.) SQLstate(01000) vendor code(5701) SQLWarning: reason([Microsoft][ODBC SQL Server Driver][SQL Server]Changedlanguage setting to us_english.) SQLstate(01000) vendor code(5703) *Connection.getMetaData *Databa
seMetaData.getDriverName Get connection info string (SQLGetInfo), hDbc=51647304, fInfoType=6,len=300 SQLSRV32.DLL *DatabaseMetaData.getDriverVersion Get connection info string (SQLGetInfo), hDbc=51647304, fInfoType=7,len=300 03.85.1117 *DatabaseMetaData.getDriverName Get connection info string (SQLGetInfo), hDbc=51647304, fInfoType=6,len=300 SQLSRV32.DLL Driver name:    JDBC-ODBC Bridge (SQLSRV32.DLL) *DatabaseMetaData.getDriverVersion Get connection info string (SQLGetInfo), hDbc=51647304, fInfoType=7,len=300 03.85.1117 Driver version: 2.0001 (03.85.1117) Caching SQL type information *Connection.getMetaData *DatabaseMetaData.getTypeInfo Allocating Statement Handle (SQLAllocStmt), hDbc=51647304 hStmt=51650696 Get type info (SQLGetTypeInfo), hStmt=51650696, fSqlType=0 Number of result columns (SQLNumResultCols), hStmt=51650696 value=20 Get connection info string (SQLGetInfo), hDbc=51647304, fInfoType=10,len=300 03.52.0000 Fetching (SQLFetch), hStmt=51650696 Column attributes (
SQLColAttributes), hStmt=51650696, icol=1, type=2 value (int)=-9 Column attributes (SQLColAttributes), hStmt=51650696, icol=1, type=3 value (int)=256 Get string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 sql_variant Get integer data (SQLGetData), hStmt=51650696, column=2 value=-150 Get integer data (SQLGetData), hStmt=51650696, column=3 value=8000 Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 uniqueidentifier Get integer data (SQLGetData), hStmt=51650696, column=2 value=-11 Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 ntext Get integer data (SQLGetData), hStmt=51650696, column=2 value=-10 Get integer data (SQLGetData), hStmt=51650696, column=3 value=1073741823 Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 nvarchar Get integer data (SQLGetData), hStmt=51650696, column=2 value=-9 Get integer data
 (SQLGetData), hStmt=51650696, column=3 value=4000 Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 sysname Get integer data (SQLGetData), hStmt=51650696, column=2 value=-9 Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 nchar Get integer data (SQLGetData), hStmt=51650696, column=2 ResultSet.finalize sun.jdbc.odbc.JdbcOdbcResultSet@30d82d Connection.finalize sun.jdbc.odbc.JdbcOdbcConnection@c09554 *Connection.close 0 Statement(s) to close ResultSet.finalize sun.jdbc.odbc.JdbcOdbcResultSet@18bf072 value=-8 Get integer data (SQLGetData), hStmt=51650696, column=3 value=4000 Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 bit Get integer data (SQLGetData), hStmt=51650696, column=2 value=-7 Get integer data (SQLGetData), hStmt=51650696, column=3 value=1 Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), h
Stmt=51650696, column=1, maxLen=257 tinyint Get integer data (SQLGetData), hStmt=51650696, column=2 value=-6 Get integer data (SQLGetData), hStmt=51650696, column=3 value=3 Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 tinyint identity Get integer data (SQLGetData), hStmt=51650696, column=2 value=-6 Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 bigint Get integer data (SQLGetData), hStmt=51650696, column=2 value=-5 Get integer data (SQLGetData), hStmt=51650696, column=3 value=19 Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 bigint identity Get integer data (SQLGetData), hStmt=51650696, column=2 value=-5 Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 image Get integer data (SQLGetData), hStmt=51650696, column=2 value=-4 Get integer data (SQLGetData), hSt
mt=51650696, column=3 value=2147483647 Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 varbinary Get integer data (SQLGetData), hStmt=51650696, column=2 value=-3 Get integer data (SQLGetData), hStmt=51650696, column=3 value=8000 Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 binary Get integer data (SQLGetData), hStmt=51650696, column=2 value=-2 Get integer data (SQLGetData), hStmt=51650696, column=3 value=8000 Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 timestamp Get integer data (SQLGetData), hStmt=51650696, column=2 value=-2 Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 text Get integer data (SQLGetData), hStmt=51650696, column=2 value=-1 Get integer data (SQLGetData), hStmt=51650696, column=3 value=2147483647 Fetching (SQLFetch), hStmt=51650696 Get 
string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 char Get integer data (SQLGetData), hStmt=51650696, column=2 value=1 Get integer data (SQLGetData), hStmt=51650696, column=3 value=8000 Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 numeric Get integer data (SQLGetData), hStmt=51650696, column=2 value=2 Get integer data (SQLGetData), hStmt=51650696, column=3 value=38 Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 numeric() identity Get integer data (SQLGetData), hStmt=51650696, column=2 value=2 Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 decimal Get integer data (SQLGetData), hStmt=51650696, column=2 value=3 Get integer data (SQLGetData), hStmt=51650696, column=3 value=38 Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 money Get integer data
 (SQLGetData), hStmt=51650696, column=2 value=3 Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 smallmoney Get integer data (SQLGetData), hStmt=51650696, column=2 value=3 Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 decimal() identity Get integer data (SQLGetData), hStmt=51650696, column=2 value=3 Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 int Get integer data (SQLGetData), hStmt=51650696, column=2 value=4 Get integer data (SQLGetData), hStmt=51650696, column=3 value=10 Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 int identity Get integer data (SQLGetData), hStmt=51650696, column=2 value=4 Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 smallint Get integer data (SQLGetData), hStmt=51650696, col
umn=2 value=5 Get integer data (SQLGetData), hStmt=51650696, column=3 value=5 Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 smallint identity Get integer data (SQLGetData), hStmt=51650696, column=2 value=5 Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 float Get integer data (SQLGetData), hStmt=51650696, column=2 value=6 Get integer data (SQLGetData), hStmt=51650696, column=3 value=15 Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 real Get integer data (SQLGetData), hStmt=51650696, column=2 value=7 Get integer data (SQLGetData), hStmt=51650696, column=3 value=7 Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 datetime Get integer data (SQLGetData), hStmt=51650696, column=2 value=11 Get integer data (SQLGetData), hStmt=51650696, column=3 value=23 Fetching (S
QLFetch), hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 smalldatetime Get integer data (SQLGetData), hStmt=51650696, column=2 value=11 Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 varchar Get integer data (SQLGetData), hStmt=51650696, column=2 value=12 Get integer data (SQLGetData), hStmt=51650696, column=3 value=8000 Fetching (SQLFetch), hStmt=51650696 End of result set (SQL_NO_DATA) *ResultSet.close Free statement (SQLFreeStmt), hStmt=51650696, fOption=1 *ResultSet has been closed Get connection info (SQLGetInfo), hDbc=51647304, fInfoType=44 int value=23 Get connection info (SQLGetInfo), hDbc=51647304, fInfoType=168 int value=8065 Get connection info (SQLGetInfo), hDbc=51647304, fInfoType=151 int value=73695 Get connection info (SQLGetInfo), hDbc=51647304, fInfoType=145 int value=69599 Get connection info (SQLGetInfo), hDbc=51647304, fInfoType=121 int value=15 Get connection info (
SQLGetInfo), hDbc=51647304, fInfoType=120 int value=2 Get connection info (SQLGetInfo), hDbc=51647304, fInfoType=153 int value=1 getConnection returningdriver[className=sun.jdbc.odbc.JdbcOdbcDriver,sun.jdbc.odbc.JdbcOdbcDriver@1f06dc3] *Connection.getMetaData *DatabaseMetaData.getURL *DatabaseMetaData.getDriverName Get connection info string (SQLGetInfo), hDbc=51647304, fInfoType=6,len=300 SQLSRV32.DLL *DatabaseMetaData.getDriverVersion Get connection info string (SQLGetInfo), hDbc=51647304, fInfoType=7,len=300 03.85.1117 *Connection.close 0 Statement(s) to close Disconnecting (SQLDisconnect), hDbc=51647304 Closing connection (SQLFreeConnect), hDbc=51647304 Closing environment (SQLFreeEnv), hEnv=51647136
> 

0
Joe
1/2/2005 7:17:52 PM
Stuart Leonard wrote:
> I have downloaded the MS SQL Server 2000 Enterprise Evaluation edition, and
> the MS SQL 2000 Server JDBC driver.

FWIW, the M$ JDBC driver hasn't been well reviewed. I'd advise you to 
pick up a copy of the jTDS driver instead. Not that this is the answer 
to your problem, but it might be a good thing just the same.

Luke
0
Luke
1/2/2005 11:55:12 PM
Joe, thanks for the tip.  I am running Windows XP Professional OS.  I 
modified the Windows Firewall "Exceptions" tab on the node computer to allow 
port 1433.  That resolved the problem.  However, since I am not a network 
admin,  I am not sure that doing this was the best solution, but it worked.

"Joe Weinstein" <joeNOSPAM@bea.com> wrote in message 
news:41D848E0.5070600@bea.com...
> Hi. In order for the jdbc driver to connect to the DBMS, the DBMS needs to 
> be
> configured to listen for TCP connection requests. It does not do this by 
> default.
> Ie: "Mixed mode" connections in setup. 1433 is the default port for a 
> SQLServer
> to use for tcp connections. You should verify that the DBMS is using that 
> port...
> Joe Weinstein at BEA
>
> Stuart Leonard wrote:
>
>> I have downloaded the MS SQL Server 2000 Enterprise Evaluation edition, 
>> and
>> the MS SQL 2000 Server JDBC driver.
>>
>> I have installed and configured the MS SQL Server 2000 onto two 
>> computers,
>> which reside on the same network.  (In fact, these two computers comprise
>> the entire network).
>>
>> The network server (computer name=SUNCDS1), and the lone node (SUNCDS2),
>> each have their own SQL Server 2000 instance.
>>
>> The SQL Server 2000 Enterprise Manager console on SUNCDS1 shows both SQL
>> Server instances, the (local) instance, which is SUNCDS1, and also 
>> SUNCDS2.
>> It may be worthwhile to mention that the SUNCDS2 instance on the 
>> Enterprise
>> console does not show the SQL Server Agent as being started, but I can
>> navigate to the SUNCDS2 databases, and display the table information.  If 
>> I
>> try to start the SQL Server Agent for SUNCDS2, I receive the message 
>> "Access
>> is Denied".  The enterprise console on the SUNCDS2 machine indeed shows 
>> the
>> SQL Server Agent as being started.
>>
>> I have written a sample Java application that uses both the MS SQL Server
>> ODBC driver and a JDBC type 4 driver (MS SQL Server 2000 JDBC) to 
>> establish
>> a connection to the SUNCDS2 instance.  This application resides on the
>> SUNCDS1 network server.  The ODBC driver will connect to SUNCDS2 instance
>> wihout a problem.
>>
>> The JDBC driver does not connect to SUNCDS2.  The JDBC driver will, 
>> however,
>> connect to the local SQL Server instance that resides on SUNCDS1.
>>
>> Following are the code snippet to establish the JDBC driver connection, 
>> and
>> also the DriverManager logging messages that show the failure.  (I have 
>> also
>> included the messages regarding the successful ODBC connection to SUNCDS2 
>> at
>> the end of this post, for what it's worth).
>>
>> static void testJDBCConnection()
>>  {
>>     System.out.println("testing JDBC connection type 4");
>>  Driver d = null;
>>  DriverManager.println("===================== testing JDBC connection 
>> type 4
>> =====================");
>>
>>  try {
>>   d =
>> (Driver)Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
>>
>>   Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
>>   } catch (InstantiationException e) {e.printStackTrace();}
>>     catch (IllegalAccessException e) {e.printStackTrace();}
>>     catch (ClassNotFoundException e) {
>>          e.printStackTrace();}
>>     try
>>     {
>>         String url =
>> "jdbc:microsoft:sqlserver://SUNCDS2:1433;databaseName=master";
>>         System.out.println(url);
>>         System.out.println(d);
>>         Connection conn = DriverManager.getConnection(url, "sa", 
>> "scd123");
>>         DatabaseMetaData dma = conn.getMetaData ();
>>   System.out.println("\nConnected to " + dma.getURL());
>>   System.out.println("Driver       " +    dma.getDriverName());
>>   System.out.println("Version      " +   dma.getDriverVersion());
>>   System.out.println("");
>>   conn.close();
>>
>>     }
>>     catch (SQLException e) {e.printStackTrace();}
>>  }
>>
>>
>> ===================== testing JDBC connection type 4 
>> =====================
>>  registerDriver:
>> driver[className=com.microsoft.jdbc.sqlserver.SQLServerDriver,com.microsoft.jdbc.sqlserver.SQLServerDriver@7a1576]
>> 
>> DriverManager.getConnection("jdbc:microsoft:sqlserver://SUNCDS2:1433;databaseName=master") 
>> tryingdriver[className=sun.jdbc.odbc.JdbcOdbcDriver,sun.jdbc.odbc.JdbcOdbcDriver@1f06dc3] 
>> *Driver.connect(jdbc:microsoft:sqlserver://SUNCDS2:1433;databaseName=master) 
>> tryingdriver[className=com.microsoft.jdbc.sqlserver.SQLServerDriver,com.microsoft.jdbc.sqlserver.SQLServerDriver@7a1576] 
>> Connection.finalize sun.jdbc.odbc.JdbcOdbcConnection@79e304 
>> *Connection.close 0 Statement(s) to close ResultSet.finalize 
>> sun.jdbc.odbc.JdbcOdbcResultSet@273686 java.sql.SQLException: 
>> [Microsoft][SQLServer 2000 Driver forJDBC]Connectiontimed out: connect at 
>> com.microsoft.jdbc.base.BaseExceptions.createException(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(UnknownSource) 
>> at com.microsoft.jdbc.base.BaseConnection.getNewImplC
> onnection(UnknownSource) 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:512) at 
> java.sql.DriverManager.getConnection(DriverManager.java:171) at 
> SQLConnection.testJDBCConnection(SQLConnection.java:228) at 
> SQLConnection.getDBConnection(SQLConnection.java:117) at 
> SQLConnection.test(SQLConnection.java:22) at 
> SQLConnection$1.actionPerformed(SQLConnection.java:66) at 
> javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1786) 
> atjavax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1839) 
> atjavax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel..java:420) 
> at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258) 
> atjavax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:245) 
> at java.awt.Component.processMouseEvent(Component.java:5100) at 
> java.awt.Compone
> nt.processEvent(Component.java:4897) at 
> java.awt.Container.processEvent(Container.java:1569) at 
> java.awt.Component.dispatchEventImpl(Component.java:3615) at 
> java.awt.Container.dispatchEventImpl(Container.java:1627) at 
> java.awt.Component.dispatchEvent(Component.java:3477) at 
> java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3483) at 
> java.awt.LightweightDispatcher.processMouseEvent(Container.java:3198) at 
> java.awt.LightweightDispatcher.dispatchEvent(Container.java:3128) at 
> java.awt.Container.dispatchEventImpl(Container.java:1613) at 
> java.awt.Window.dispatchEventImpl(Window.java:1606) at 
> java.awt.Component.dispatchEvent(Component.java:3477) at 
> java.awt.EventQueue.dispatchEvent(EventQueue.java:456) 
> atjava.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201) 
> atjava.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151) 
> at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145) 
> at java.awt.EventDispatchThr
> ead.pumpEvents(EventDispatchThread.java:137) at 
> java.awt.EventDispatchThread.run(EventDispatchThread.java:100) 
> SQLException: SQLState(HY000) java.sql.SQLException: [Microsoft][SQLServer 
> 2000 Driver for JDBC]Errorestablishing 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(UnknownSource) 
> at 
> com.microsoft.jdbc.base.BaseConnection.getNewImplConnection(UnknownSource) 
> 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:512) at 
> java.sql.DriverManager.getConnection(DriverManager.java:171) at 
> SQLConnection.testJDBCConnection(SQLConnection.java:228) a
> t SQLConnection.getDBConnection(SQLConnection.java:117) at 
> SQLConnection.test(SQLConnection.java:22) at 
> SQLConnection$1.actionPerformed(SQLConnection.java:66) at 
> javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1786) 
> atjavax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1839) 
> atjavax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420) 
> at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258) 
> atjavax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:245) 
> at java.awt.Component.processMouseEvent(Component.java:5100) at 
> java.awt.Component.processEvent(Component.java:4897) at 
> java.awt.Container.processEvent(Container.java:1569) at 
> java.awt.Component.dispatchEventImpl(Component.java:3615) at 
> java.awt.Container.dispatchEventImpl(Container.java:1627) at 
> java.awt.Component.dispatchEvent(Component.java:3477) at 
> java.awt.LightweightDispatcher.retargetMouseEvent(Container.java
> :3483) at 
> java.awt.LightweightDispatcher.processMouseEvent(Container.java:3198) at 
> java.awt.LightweightDispatcher.dispatchEvent(Container.java:3128) at 
> java.awt.Container.dispatchEventImpl(Container.java:1613) at 
> java.awt.Window.dispatchEventImpl(Window.java:1606) at 
> java.awt.Component.dispatchEvent(Component.java:3477) at 
> java.awt.EventQueue.dispatchEvent(EventQueue.java:456) 
> atjava.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201) 
> atjava.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151) 
> at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145) 
> at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137) 
> at java.awt.EventDispatchThread.run(EventDispatchThread.java:100) 
> SQLException: SQLState(08001) getConnection failed: java.sql.SQLException: 
> [Microsoft][SQLServer 2000Driver for JDBC]Error establishing socket. 
> :===================== testing ODBC connection ===================== 
> DriverManager.g
> etConnection("jdbc:odbc:Driver={SQLServer};Server=SUNCDS2;Database=master;UID=sa; 
> PWD=scd123") 
> tryingdriver[className=sun.jdbc.odbc.JdbcOdbcDriver,sun.jdbc.odbc.JdbcOdbcDriver@1f06dc3] 
> *Driver.connect 
> (jdbc:odbc:Driver={SQLServer};Server=SUNCDS2;Database=master;UID=sa; 
> PWD=scd123) JDBC to ODBC Bridge: Checking security No SecurityManager 
> present, assuming trusted application/applet Allocating Environment handle 
> (SQLAllocEnv) hEnv=51647136 Allocating Connection handle (SQLAllocConnect) 
> hDbc=51647304 Connecting (SQLDriverConnect), hDbc=51647304, 
> szConnStrIn=Driver={SQLServer};Server=SUNCDS2;Database=master;UID=sa; 
> PWD=scd123 RETCODE = 1 WARNING - Generating SQLWarning... SQLWarning: 
> reason([Microsoft][ODBC SQL Server Driver][SQL Server]Changeddatabase 
> context to 'master'.) SQLstate(01000) vendor code(5701) SQLWarning: 
> reason([Microsoft][ODBC SQL Server Driver][SQL Server]Changedlanguage 
> setting to us_english.) SQLstate(01000) vendor code(5703) 
> *Connection.getMetaData *Databa
> seMetaData.getDriverName Get connection info string (SQLGetInfo), 
> hDbc=51647304, fInfoType=6,len=300 SQLSRV32.DLL 
> *DatabaseMetaData.getDriverVersion Get connection info string 
> (SQLGetInfo), hDbc=51647304, fInfoType=7,len=300 03.85.1117 
> *DatabaseMetaData.getDriverName Get connection info string (SQLGetInfo), 
> hDbc=51647304, fInfoType=6,len=300 SQLSRV32.DLL Driver name:    JDBC-ODBC 
> Bridge (SQLSRV32.DLL) *DatabaseMetaData.getDriverVersion Get connection 
> info string (SQLGetInfo), hDbc=51647304, fInfoType=7,len=300 03.85.1117 
> Driver version: 2.0001 (03.85.1117) Caching SQL type information 
> *Connection.getMetaData *DatabaseMetaData.getTypeInfo Allocating Statement 
> Handle (SQLAllocStmt), hDbc=51647304 hStmt=51650696 Get type info 
> (SQLGetTypeInfo), hStmt=51650696, fSqlType=0 Number of result columns 
> (SQLNumResultCols), hStmt=51650696 value=20 Get connection info string 
> (SQLGetInfo), hDbc=51647304, fInfoType=10,len=300 03.52.0000 Fetching 
> (SQLFetch), hStmt=51650696 Column attributes (
> SQLColAttributes), hStmt=51650696, icol=1, type=2 value (int)=-9 Column 
> attributes (SQLColAttributes), hStmt=51650696, icol=1, type=3 value 
> (int)=256 Get string data (SQLGetData), hStmt=51650696, column=1, 
> maxLen=257 sql_variant Get integer data (SQLGetData), hStmt=51650696, 
> column=2 value=-150 Get integer data (SQLGetData), hStmt=51650696, 
> column=3 value=8000 Fetching (SQLFetch), hStmt=51650696 Get string data 
> (SQLGetData), hStmt=51650696, column=1, maxLen=257 uniqueidentifier Get 
> integer data (SQLGetData), hStmt=51650696, column=2 value=-11 Fetching 
> (SQLFetch), hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, 
> column=1, maxLen=257 ntext Get integer data (SQLGetData), hStmt=51650696, 
> column=2 value=-10 Get integer data (SQLGetData), hStmt=51650696, column=3 
> value=1073741823 Fetching (SQLFetch), hStmt=51650696 Get string data 
> (SQLGetData), hStmt=51650696, column=1, maxLen=257 nvarchar Get integer 
> data (SQLGetData), hStmt=51650696, column=2 value=-9 Get integer data
> (SQLGetData), hStmt=51650696, column=3 value=4000 Fetching (SQLFetch), 
> hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, 
> maxLen=257 sysname Get integer data (SQLGetData), hStmt=51650696, column=2 
> value=-9 Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), 
> hStmt=51650696, column=1, maxLen=257 nchar Get integer data (SQLGetData), 
> hStmt=51650696, column=2 ResultSet.finalize 
> sun.jdbc.odbc.JdbcOdbcResultSet@30d82d Connection.finalize 
> sun.jdbc.odbc.JdbcOdbcConnection@c09554 *Connection.close 0 Statement(s) 
> to close ResultSet.finalize sun.jdbc.odbc.JdbcOdbcResultSet@18bf072 
> value=-8 Get integer data (SQLGetData), hStmt=51650696, column=3 
> value=4000 Fetching (SQLFetch), hStmt=51650696 Get string data 
> (SQLGetData), hStmt=51650696, column=1, maxLen=257 bit Get integer data 
> (SQLGetData), hStmt=51650696, column=2 value=-7 Get integer data 
> (SQLGetData), hStmt=51650696, column=3 value=1 Fetching (SQLFetch), 
> hStmt=51650696 Get string data (SQLGetData), h
> Stmt=51650696, column=1, maxLen=257 tinyint Get integer data (SQLGetData), 
> hStmt=51650696, column=2 value=-6 Get integer data (SQLGetData), 
> hStmt=51650696, column=3 value=3 Fetching (SQLFetch), hStmt=51650696 Get 
> string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 tinyint 
> identity Get integer data (SQLGetData), hStmt=51650696, column=2 value=-6 
> Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), 
> hStmt=51650696, column=1, maxLen=257 bigint Get integer data (SQLGetData), 
> hStmt=51650696, column=2 value=-5 Get integer data (SQLGetData), 
> hStmt=51650696, column=3 value=19 Fetching (SQLFetch), hStmt=51650696 Get 
> string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 bigint 
> identity Get integer data (SQLGetData), hStmt=51650696, column=2 value=-5 
> Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), 
> hStmt=51650696, column=1, maxLen=257 image Get integer data (SQLGetData), 
> hStmt=51650696, column=2 value=-4 Get integer data (SQLGetData), hSt
> mt=51650696, column=3 value=2147483647 Fetching (SQLFetch), hStmt=51650696 
> Get string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 
> varbinary Get integer data (SQLGetData), hStmt=51650696, column=2 value=-3 
> Get integer data (SQLGetData), hStmt=51650696, column=3 value=8000 
> Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), 
> hStmt=51650696, column=1, maxLen=257 binary Get integer data (SQLGetData), 
> hStmt=51650696, column=2 value=-2 Get integer data (SQLGetData), 
> hStmt=51650696, column=3 value=8000 Fetching (SQLFetch), hStmt=51650696 
> Get string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 
> timestamp Get integer data (SQLGetData), hStmt=51650696, column=2 value=-2 
> Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), 
> hStmt=51650696, column=1, maxLen=257 text Get integer data (SQLGetData), 
> hStmt=51650696, column=2 value=-1 Get integer data (SQLGetData), 
> hStmt=51650696, column=3 value=2147483647 Fetching (SQLFetch), 
> hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, 
> maxLen=257 char Get integer data (SQLGetData), hStmt=51650696, column=2 
> value=1 Get integer data (SQLGetData), hStmt=51650696, column=3 value=8000 
> Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), 
> hStmt=51650696, column=1, maxLen=257 numeric Get integer data 
> (SQLGetData), hStmt=51650696, column=2 value=2 Get integer data 
> (SQLGetData), hStmt=51650696, column=3 value=38 Fetching (SQLFetch), 
> hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, 
> maxLen=257 numeric() identity Get integer data (SQLGetData), 
> hStmt=51650696, column=2 value=2 Fetching (SQLFetch), hStmt=51650696 Get 
> string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 decimal Get 
> integer data (SQLGetData), hStmt=51650696, column=2 value=3 Get integer 
> data (SQLGetData), hStmt=51650696, column=3 value=38 Fetching (SQLFetch), 
> hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, 
> maxLen=257 money Get integer data
> (SQLGetData), hStmt=51650696, column=2 value=3 Fetching (SQLFetch), 
> hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, 
> maxLen=257 smallmoney Get integer data (SQLGetData), hStmt=51650696, 
> column=2 value=3 Fetching (SQLFetch), hStmt=51650696 Get string data 
> (SQLGetData), hStmt=51650696, column=1, maxLen=257 decimal() identity Get 
> integer data (SQLGetData), hStmt=51650696, column=2 value=3 Fetching 
> (SQLFetch), hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, 
> column=1, maxLen=257 int Get integer data (SQLGetData), hStmt=51650696, 
> column=2 value=4 Get integer data (SQLGetData), hStmt=51650696, column=3 
> value=10 Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), 
> hStmt=51650696, column=1, maxLen=257 int identity Get integer data 
> (SQLGetData), hStmt=51650696, column=2 value=4 Fetching (SQLFetch), 
> hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, 
> maxLen=257 smallint Get integer data (SQLGetData), hStmt=51650696, col
> umn=2 value=5 Get integer data (SQLGetData), hStmt=51650696, column=3 
> value=5 Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), 
> hStmt=51650696, column=1, maxLen=257 smallint identity Get integer data 
> (SQLGetData), hStmt=51650696, column=2 value=5 Fetching (SQLFetch), 
> hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, column=1, 
> maxLen=257 float Get integer data (SQLGetData), hStmt=51650696, column=2 
> value=6 Get integer data (SQLGetData), hStmt=51650696, column=3 value=15 
> Fetching (SQLFetch), hStmt=51650696 Get string data (SQLGetData), 
> hStmt=51650696, column=1, maxLen=257 real Get integer data (SQLGetData), 
> hStmt=51650696, column=2 value=7 Get integer data (SQLGetData), 
> hStmt=51650696, column=3 value=7 Fetching (SQLFetch), hStmt=51650696 Get 
> string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 datetime 
> Get integer data (SQLGetData), hStmt=51650696, column=2 value=11 Get 
> integer data (SQLGetData), hStmt=51650696, column=3 value=23 Fetching (S
> QLFetch), hStmt=51650696 Get string data (SQLGetData), hStmt=51650696, 
> column=1, maxLen=257 smalldatetime Get integer data (SQLGetData), 
> hStmt=51650696, column=2 value=11 Fetching (SQLFetch), hStmt=51650696 Get 
> string data (SQLGetData), hStmt=51650696, column=1, maxLen=257 varchar Get 
> integer data (SQLGetData), hStmt=51650696, column=2 value=12 Get integer 
> data (SQLGetData), hStmt=51650696, column=3 value=8000 Fetching 
> (SQLFetch), hStmt=51650696 End of result set (SQL_NO_DATA) 
> *ResultSet.close Free statement (SQLFreeStmt), hStmt=51650696, fOption=1 
> *ResultSet has been closed Get connection info (SQLGetInfo), 
> hDbc=51647304, fInfoType=44 int value=23 Get connection info (SQLGetInfo), 
> hDbc=51647304, fInfoType=168 int value=8065 Get connection info 
> (SQLGetInfo), hDbc=51647304, fInfoType=151 int value=73695 Get connection 
> info (SQLGetInfo), hDbc=51647304, fInfoType=145 int value=69599 Get 
> connection info (SQLGetInfo), hDbc=51647304, fInfoType=121 int value=15 
> Get connection info (
> SQLGetInfo), hDbc=51647304, fInfoType=120 int value=2 Get connection info 
> (SQLGetInfo), hDbc=51647304, fInfoType=153 int value=1 getConnection 
> returningdriver[className=sun.jdbc.odbc.JdbcOdbcDriver,sun.jdbc.odbc.JdbcOdbcDriver@1f06dc3] 
> *Connection.getMetaData *DatabaseMetaData.getURL 
> *DatabaseMetaData.getDriverName Get connection info string (SQLGetInfo), 
> hDbc=51647304, fInfoType=6,len=300 SQLSRV32.DLL 
> *DatabaseMetaData.getDriverVersion Get connection info string 
> (SQLGetInfo), hDbc=51647304, fInfoType=7,len=300 03.85.1117 
> *Connection.close 0 Statement(s) to close Disconnecting (SQLDisconnect), 
> hDbc=51647304 Closing connection (SQLFreeConnect), hDbc=51647304 Closing 
> environment (SQLFreeEnv), hEnv=51647136
>>
> 


0
Stuart
1/3/2005 3:12:49 AM
Irrespective of the driver used, MS SQL will still need to communicate
over port 1433 (or some other port that we define), right?

So, if I want to communicate over a network to a Machine running MS SQL
(or any other DB) I will need to open a port, right?

- manzoor

0
Manzoorul
1/6/2005 4:59:39 PM
Reply: