java - Help me create a jTDS connection string -
My SQL server instance name is MYPC \ SQLEXPRESS and I'm trying to create a jTDS connection string to connect to the database I am 'blog' Can anyone help me out?
I am trying to do this:
DriverManager.getConnection ("jdbc: jtds: sqlserver: //127.0.0.1: 1433 / blog", "user "," password ");
And I get it:
java.sql.SQLException: Network error IOException: Connection refused on net.sourceforge.jtds.jdbc.ConnectionJDBC2 Connect. & Lt; Init & gt; At net.sourceforge.jtds.jdbc.ConnectionJDBC3 (ConnectionJDBC2.java:395). & Lt; Init & gt; On net.sourceforge.jtds.jdbc.Driver.connect (ConnectionJDBC3.java:50) (Driver.java: main.main (java.sql.DriverManager.getConnection (Unknown Source SqlConnection.Connect on main.java:11) ( SqlConnection.java:19) caused java.sql.DriverManager.getConnection (unknown source) at 184)) by: java.net.ConnectException: connection refused: java.net on java.net.PlainSocketImpl.connectToAddress in Java. JavaknetkPlainSocketImplksocketConnect (Native method PlainSocketImpl.doConnect) on (unknown source) (unknown source) connected .net.PlainSocketImpl.connect (java.net.SocksSocketImpl.connect (unknown source) at an undisclosed source) on java .net.Socket.connect (unknown source) at sun.reflectNativeMethodAccessorImplkinvoke0 SunkreflectkNativeMethodAccessorImplkinvoke at (Native Method) (Unknown Source) (unknown source SunkreflectkDelegatingMethodAccessorImplkinvoke) (unknown source java.lang.reflect.Method.invoke) on net.sourceforge . Jtds.jdbc.SharedSocket.createSocketForJDBC3 (SharedSocket.java:305) net.sourceforge.jtds.jdbc.SharedSocket. & Lt; Init & gt; (SharedSocket.java:255) at net.sourceforge.jtds.jdbc.ConnectionJDBC2. & Lt; & Gt; init; (Connection JDBC2.java:323) ... 6 more detailed as
JTDS is the URL format for jTDS:
JDBC: jtds: & lt; SERVER_TYPE & gt ;: // to & lt; Server & gt; [: & Lt; Harbor & gt;] [/ & lt; Database & gt;] [; Therefore, to connect to a database called "Blog" hosted by an MS SQL server running on MYPC, & lt; Property & gt; = & Lt; Value & gt;
, you might end up with something like this:
jdbc: jtds: sqlserver: // MYPC: 1433 / blog; Example = If you getConnection (url, "There sa want to use", "s3cr3t"), then / s>
> jdbc: jtds: sqlserver: // MYPC: 1433 / blog; Example = SQLEXPRESS
Edit: Your refused connection with connection
, double check that you have SQL Running the server, the service is running and you do not have a firewall incoming connection blocked.
Comments
Post a Comment