Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cant connect to remote SQL server database

Status
Not open for further replies.

indiaone

Programmer
Jun 27, 2007
1
IN
hi experts,
i have a problem ....
i m writing a java code to connect to the sqlserver runnign in a machine in the same domain,
i m using the sql-jdbc driver for that ....which comes as sqljdbc.jar,
the code follows:
private String driverName = "com.microsoft.sqlserver.jdbc.SQLServerDriver";

private String databaseURL = "jdbc:sqlserver://192.168.123.345:1433;databaseName=MyPrivateDB";
private String username = "sa";
private String password = "";
Class.forName(driverName);
con = DriverManager.getConnection(databaseURL,username,password);

now the last line of the code throws an error:
com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host has failed. java.net.ConnectException: Connection refused: connect

BUT BUT

the same code runs successfully, when i use JDBC-ODBC bridge driver to connect

why so?
 
You should use the Java forum for this kind of issues.

Maybe the answer is that you java a ODBC data source defined but not a jdbc one.

Cheers,
Dian
 
Is there any firewall working?

It seems to me that the Connection is blocked.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top