java.sql.SQLException: Network error IOException: Connection timed out: connect at net.sourceforge.jtds.jdbc.ConnectionJDBC2.(ConnectionJDBC2.java:410) at net.sourceforge.jtds.jdbc.ConnectionJDBC3.(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 mahesh.MyFrame.connectToServer(MyFrame.java:50) at mahesh.DataCount.main(DataCount.java:18) Caused by: java.net.ConnectException: Connection timed out: connect at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333) at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366) at java.net.Socket.connect(Socket.java:519) 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.(SharedSocket.java:257) at net.sourceforge.jtds.jdbc.ConnectionJDBC2.(ConnectionJDBC2.java:311) … 6 more
Can anyone help me in getting rid of this exception?
here is my java code
**Class.forName(“net.sourceforge.jtds.jdbc.Driver”);
Connection connection = DriverManager.getConnection(“jdbc:jtds:sqlserver://mindmill:1433/employ”,”mahesh”,”mahesh”);**
As the jTDS FAQ states, the URL must be in the form
Infering from your connection:
From here on, you must set other sql connection parameters. I’ll post you my code:
The output of my program:
The lessons here:
Any other problems, just tell me.
EDIT:
The best case would be if you have already tried this connection with your pc as a Server, I mean your pc must have Sql Server 2005 installed, NetBeans installed and the project already setted up and running (as a proof of concept to connect the database).
Even if you haven’t do the step before, there is a set of questions you should have answered before trying to connect a remote server:
Let me know any more issues after you have answered this questions before.