I am using
- Windows 7
- Netbeans IDE 7.1.2
- SQL Server Management Studio Express 2005
- JDK1.6
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:
- In SQL Server Configuration Manager, Protocols for SQLEXPRESS : TCP/IP Enabled
In fact I made enable remaining 3 too.
- SQL Server(SQLExpress) and SQL Browser Service both are running.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…