Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Verifying that SQL Server is listening.

0 views
Skip to first unread message

Perry Sandoval

unread,
Nov 10, 2001, 11:46:21 PM11/10/01
to
Hi y'all,

I've finally gotten passed the little MS JDBC annoyances
like corrupt jar files (see Susan Barretta's post). And
wrong classpath (Joe Weinstein helped here). However, I
still cannot connect. So, I set up a local server running
Win2k and SQLServer 2K. I put the ip address, port, and
database name in the connection string like this.

cnx="jdbc:microsoft:sqlserver://192.168.1.3:1433;DatabaseName=NorthWind"

So, guess what? It works!! HOWEVER. If I change the ip
address to the production server I repeatedly get the
message error establishing socket (Northwind is also on the
prod server). Like this:

Exception in thread "main" java.sql.SQLException:
[Microsoft][SQLServer JDBC Driver]Error establishing
socket.
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:517)
at
java.sql.DriverManager.getConnection(DriverManager.java:177)
at s2k_test.main(s2k_test.java:23)

So, it has to be that server right?

Can someone please tell me how to verify the following:
1) is SQL Server 2000 really listening (is there a dialog
box I can visit).
2) is it listening on port 1433 (is this set somewhere).

I can connect to the database from another server running
IIS & ASP but can't through the Java-MSJDBC combo.

I have verified the machines IP address.
I have verified the name of the database.
I have verified the account name and password.

Any other clues?

btw: I'm running Java on Linx for both the working and
now-working examples.

Thanks alot for any information better than what I have
now.

Perry

Joseph Weinstein

unread,
Nov 12, 2001, 1:38:01 PM11/12/01
to Perry Sandoval
Hi. The DBMS is porbably not yet configured to listen for
tcpip connection attempts, or much less likely, it is
listening on another port. Here's a cheap program that
will tell you if something is listening on a given machine/port:

import java.io.*;
import java.net.*;

public class isAnythingListeningOn
{
public static void main(String argv[])
throws Exception
{
if (argv.length != 2)
{
System.out.println("Usage: isAnythingListeningOn <host> <port>");
System.out.println("eg:\n% java isAnythingListeningOn myMachine 1433");
System.exit(0);
}

try
{
System.out.println("\nTrying to open a socket with host "
+ argv[0] + " and port " + argv[1] + " ...");
Socket socket = new Socket(argv[0],(new Integer(argv[1]).intValue()));
System.out.println("\nYes, there is, we got a socket.");
socket.close();
}
catch (Exception e)
{
System.out.println("We failed to open a socket. Here's why:\n");
e.printStackTrace();
System.out.println("\n(Either there is no machine named '" + argv[0]
+ "' or\nnothing is listening there on port "
+ argv[1] +")\n");
}
}
}

eg:

C:\joe>java isAnythingListeningOn qa75 1433

Trying to open a socket with host qa75 and port 1433 ...

Yes, there is, we got a socket.

C:\joe>java isAnythingListeningOn qa75 1432

Trying to open a socket with host qa75 and port 1432 ...
We failed to open a socket. Here's why:

java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at isAnythingListeningOn.main(isAnythingListeningOn.java:20)

(Either there is no machine named 'qa75' or
nothing is listening there on port 1432)

0 new messages