查看: 1166|回复: 2
|
Java connect 不到 Microsoft SQL Server 2005 express edition
[复制链接]
|
|
我用netbean试着connect 去 Microsoft SQL Server 2005 express edition
import java.sql.*;
public class DBConnect {
private Connection con;
private Statement st;
private ResultSet rs;
public DBConnect(){
try{
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/Try","sa","");
st = con.createStatement();
}catch(Exception ex){
System.out.println("Error : " + ex);
}
}
public void getData(){
try{
String query = "Select * from People";
rs = st.executeQuery(query);
System.out.println("Records from database");
while(rs.next()){
String name = rs.getString("Name");
String age = rs.getString("Age");
System.out.println("Name: "+name+ " . " + "Age : " + age);
}
}catch(Exception ex){
System.out.println( ex);
}
}
}
可是出这个 error message (com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure)
请问谁知道该怎么做? 本帖最后由 YogurtBear 于 23-2-2014 09:30 PM 编辑
|
|
|
|
|
|
|
|
发表于 23-2-2014 07:54 PM
|
显示全部楼层
MySQL哪里有2005 Express Edition的???????????? |
|
|
|
|
|
|
|

楼主 |
发表于 23-2-2014 09:28 PM
|
显示全部楼层
geekman 发表于 23-2-2014 07:54 PM 
MySQL哪里有2005 Express Edition的????????????
对不起,是我搞错了,Microsoft SQL Server 2005
|
|
|
|
|
|
|
| |
本周最热论坛帖子
|