• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JDBC Connection??

 
Yu Tao
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
package sqlServer;

import java.sql.Connection;
import java.sql.DriverManager;

public class SQLServerTest {
public static void main(String[] args) {
try {
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
Connection con = DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=Northwind", "sa", "");
System.out.println("TEST");
} catch(Exception e) {
System.out.println(e);
}
}
}

Excepton
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.

why ???
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yu,

why ???

  • Because SQL Server is not running?
  • Because you are using the wrong port?
  • Because SQL Server is not listening for database connections?


  • Have you tried the Microsoft Web site?

    Good Luck,
    Avi.
     
    Yu Tao
    Greenhorn
    Posts: 28
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Originally posted by Avi Abrami:
    Yu,

  • Because SQL Server is not running?
  • Because you are using the wrong port?
  • Because SQL Server is not listening for database connections?


  • Have you tried the Microsoft Web site?

    Good Luck,
    Avi.


    1 My SQL Server is runing
    2 SQL Server port is 1433 this is SQL Server dafault port
    3 I can use ODBC to connetion SQL Server except JDBC.

    why???
     
    David Harkness
    Ranch Hand
    Posts: 1646
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Is the database truly named Northwind? Do you have two TCP/IP interfaces, thus "localhost" is ambiguous (try your real machine name)?
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic