查看: 864|回复: 3
|
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:29 PM 编辑
|
|
|
|
|
|
|
|
发表于 23-2-2014 05:50 PM
|
显示全部楼层
Mysql 2005 express edition听起来很奇怪
你确定你用的是mysql? 还是Microsoft SQL Server 2005 express edition? |
|
|
|
|
|
|
|
发表于 23-2-2014 07:55 PM
|
显示全部楼层
MySQL哪里有2005 Express Edition的???????????? |
|
|
|
|
|
|
|

楼主 |
发表于 23-2-2014 09:27 PM
|
显示全部楼层
nsda 发表于 23-2-2014 05:50 PM 
Mysql 2005 express edition听起来很奇怪
你确定你用的是mysql? 还是Microsoft SQL Server 2005 express e ...
MySQL 跟Microsoft SQL Server 2005 不一样的啊?>.<
我的是Microsoft SQL Server 2005 xD
是我搞错了,不好意思 |
|
|
|
|
|
|
| |
本周最热论坛帖子
|