LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 712|回复: 2

连接mysql的问题!!

[复制链接]
发表于 2005-3-16 13:57:47 | 显示全部楼层 |阅读模式
Windows下用记事本写了段java代码:
import java.sql.*;
public class Test{
public static void main(String args[]){
Connection conn=null;
String sql="jdbc:mysql://127.0.0.1/my?user=root&password=root&useUnicode=true&characterEncoding=GB2312";
try{
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
}
catch (Exception E) {
   System.out.println("Unable to load driver.");
}
try{
   conn = DriverManager.getConnection(sql);     
}catch(Exception e){     
   System.out.println(e);
}
try{
   Statement stmt = conn.createStatement();
}catch(Exception e){     
   System.out.println(e);
}
}
}

加载驱动没有错,连接数据库的时候出这个错
java.sql.SQLException:Communicatin failure during handshake.Is there a server running on 192.168.0.102:3306?
怎么回事啊??mysql是启动了的
发表于 2005-3-16 15:05:57 | 显示全部楼层
你的root是不是全局用户?高版本的 mysql 有这个问题,只有全局用户才能用jdbc连接
回复 支持 反对

使用道具 举报

发表于 2005-3-16 18:41:20 | 显示全部楼层
检查
skip networking
选项?
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表