I have a local MS SQL Server and am trying to connect to it using JTDS in java. Here is the connection string:
Class.forName("net.sourceforge.jtds.jdbc.Driver");
Connection conn = DriverManager.getConnection("jdbc:jtds:sqlserver://localhost:1433/stock","sa","password");
And server properties:
name: USER-PC \ SQLEXPRESS
root directory: c: \ Program Files \ Microsoft SQL Server \ MSSQL11.SQLEXPRESS \ MSSQL
I get an error Exception in thread "main" java.sql.SQLException: Network error IOException: Connection refused: connect.
How can i fix this?
source
share