I am running a SQL Server Express 10.50.4000.0 on my machine. I have enabled on the TCP/IP and made sure the port is set to 1433. I have added an exception in my firewall for 1433. The server service is running. I have tried localhost and the computer name and both give the same error. When i try localhost\SQLEXPRESS or [USER-PC]\SQLEXPRESS I received an error saying it could not find the database.
String driverName = "net.sourceforge.jtds.jdbc.Driver";
Class.forName(driverName);
String serverName = "localhost";
String instanceName = "ALLEN-PC\\SQLEXPRESS";
String serverPort = "1433";
String database = serverName +":" + serverPort+"/"+instanceName;
String url = "jdbc:jtds:sqlserver://" + database;
String username = "sa";
String password = "password";
connection = DriverManager.getConnection(url, username, password);
I receive the error:
Could not connect to the database Network error IOException: Connection refused: connect
with no additional context to investigate.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With