当我尝试这样的事情时:
Class.forName("com.mysql.jdbc.Driver").newInstance(); DriverManager.getConnection("jdbc:mysql://192.168.2.116:3306/SocialFamilyTree");
我收到一个错误:
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:通信链接失败
试过:
try{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();
DriverManager.getConnection("jdbc:sqlserver://localhost:1433");
}catch(Exception e){
System.out.println("Couldn't get database connection.");
e.printStackTrace();
}
并得到:
Couldn't get database connection.
Oct 06, 2012 11:15:37 PM com.microsoft.sqlserver.jdbc.SQLServerConnection <init>