wood burning stoves
The moose likes JDBC and Relational Databases and the fly likes Problem connecting JDBC to SQL server 2008 express Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Problem connecting JDBC to SQL server 2008 express" Watch "Problem connecting JDBC to SQL server 2008 express" New topic

Problem connecting JDBC to SQL server 2008 express

Ish Fad

Joined: Aug 09, 2011
Posts: 5
I am trying to connect to SQLServer 2008 Express.
I have downloaded jtds-1.2.5.jar.
I have enable TCP/IP and user and password do exist with full right.

I am getting following error

java.sql.SQLException: Network error IOException: Connection refused: connect
at net.sourceforge.jtds.jdbc.ConnectionJDBC2.<init>(ConnectionJDBC2.java:410)
at net.sourceforge.jtds.jdbc.ConnectionJDBC3.<init>(ConnectionJDBC3.java:50)
at net.sourceforge.jtds.jdbc.Driver.connect(Driver.java:184)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at conn.DBConnecion.dbConnect(DBConnecion.java:10)
at conn.TestConnection.main(TestConnection.java:9)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:529)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at net.sourceforge.jtds.jdbc.SharedSocket.createSocketForJDBC3(SharedSocket.java:307)
at net.sourceforge.jtds.jdbc.SharedSocket.<init>(SharedSocket.java:257)
at net.sourceforge.jtds.jdbc.ConnectionJDBC2.<init>(ConnectionJDBC2.java:311)

can some one help

many thanks
Paul Clapham

Joined: Oct 14, 2005
Posts: 19728

So the database server isn't listening at whatever port you specified.

Have you checked with the manager of the database server that it is actually listening at that port? Remember that SQL Server doesn't support TCP/IP access by default, it has to be turned on.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: Problem connecting JDBC to SQL server 2008 express
jQuery in Action, 3rd edition