Σύνδεση JDBC MS SQL Server 2005
Posted: Sun Mar 02, 2008 8:20 pm
Έχω εγκαταστήσει τον Microsoft SQL Server 2005 και προσπαθώ να εγκαταστήσω μια σύνδεση την βάση. Έχω κατεβάσει τον πιο πρόσφατο driver και προσπαθώ να ορίσω το connection string, με βάση τις οδηγίες που υπάρχουν διαθέσιμες. Το λάθος που μου εμφανίζεται είναι:
SQLException: The TCP/IP connection to the host has failed. java.net.ConnectException: Connection refused: connect
SQLState: 08S01
VendorError: 0
Διάφορα ulr που έχω δοκιμάσει είναι:
String url = "jdbc:sqlserver://localhost";
String url = "jdbc:sqlserver://localhost:1433"
Καμιά ιδέα; Η εντύπωση που έχω είναι ότι το url string είναι σωστό, απλά ο SQL Server έχει κόλλημα. Έχω κάνει και Enable το TCP/IP Protocol από τον Server Configuration Manager.
Κώδικας:
String url = "jdbc:sqlserver://localhost:1433";
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();
}catch (Exception ex) { }
try
{
Connection conn = DriverManager.getConnection(url, "root", "password");
}catch (SQLException ex) {
// handle any errors
System.out.println("SQLException: " + ex.getMessage());
System.out.println("SQLState: " + ex.getSQLState());
System.out.println("VendorError: " + ex.getErrorCode());
}
SQLException: The TCP/IP connection to the host has failed. java.net.ConnectException: Connection refused: connect
SQLState: 08S01
VendorError: 0
Διάφορα ulr που έχω δοκιμάσει είναι:
String url = "jdbc:sqlserver://localhost";
String url = "jdbc:sqlserver://localhost:1433"
Καμιά ιδέα; Η εντύπωση που έχω είναι ότι το url string είναι σωστό, απλά ο SQL Server έχει κόλλημα. Έχω κάνει και Enable το TCP/IP Protocol από τον Server Configuration Manager.
Κώδικας:
String url = "jdbc:sqlserver://localhost:1433";
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();
}catch (Exception ex) { }
try
{
Connection conn = DriverManager.getConnection(url, "root", "password");
}catch (SQLException ex) {
// handle any errors
System.out.println("SQLException: " + ex.getMessage());
System.out.println("SQLState: " + ex.getSQLState());
System.out.println("VendorError: " + ex.getErrorCode());
}