jdbc MSSQL 2005 connection problem
I am trying to connect to a database I created with Microsoft SQL Sever Studio Management Express 2005 and I am receiving the following error:
com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host has failed. java.net.ConnectException: Connection refused: connect
I first tried connecting to the server M$ Management Express set up on my machine. Afterward, I got a test server and rebuilt the database on it and still can't connect. The server I tried to connect to has TCP/IP connections enabled.
Here is part of the code I have:
publicstaticfinal String DRIVER ="com.microsoft.sqlserver.jdbc.SQLServerDriver";
//jdbc:sqlserver://localhost:1433;databaseName=SLD;selectMethod=cursor
publicstaticfinal String DATABASE ="jdbc:sqlserver://Footprints-test:1433;databaseName=SLD;selectMethod=cursor";
public Connection getConnection(){
Connection c =null;
try{
Class.forName(DRIVER);
//DriverManager.registerDriver(new com.microsoft.sqlserver.jdbc.SQLServerDriver());
c = DriverManager.getConnection(DATABASE,"adam","liszka");
}catch (ClassNotFoundException ex){
ex.printStackTrace();
}catch (SQLException ex){
ex.printStackTrace();
}
return c;
}
publicstaticvoid main(String[] args){
test test =new test();
Connection c;
c = test.getConnection();
}
I also tried going through the runtime window and adding the database through that but I get the same error.
As a side note, I am able to connect to other databases because I was able to successfully add the Footprints main server through runtime.
I am using NetBeans IDE 5.5 and Java 1.6

