Reputation: 1893
I am using
I am getting the below error while connecting to the database:
com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host has failed. java.net.ConnectException: Connection refused: connect
My connection string is:
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection connection = DriverManager.getConnection(
"jdbc:sqlserver://127.0.0.1:1433;databaseName=dbcm;" +
"user=sa;password=sa");
I've checked below things:
Upvotes: 3
Views: 22174
Reputation: 24134
I followed the steps below to successfully connect to an SQLExpress instance using JDBC:
IPAll
to 1433.Microsoft's JDBC driver for SQL Server
jdbc:sqlserver://localhost;instance=SQLEXPRESS;databaseName=<your DB>;user=<your User>;password=<your Passwd>
Upvotes: 19