提示的是拒绝访问,密码跟用户名应该都是正确的,你复制我下面代码试试private static final String DRIVER_CLASS="com.mysql.jdbc.Driver"; private static final String DRIVER_URL="jdbc:mysql://localhost/bms"; private static final String DRIVER_USER="root"; private static final String DRIVER_PASSWORD="xiaoluo1370";
未给localhost root用户授权,新建一个localhost root用户,然后授权给他 create user 'root'@'localhost' identified by '你的密码'; grant all privileges on *.* to root@'localhost'; 运行这两句sql语句后试下
未给localhost root用户授权,新建一个localhost root用户,然后授权给他 create user 'root'@'localhost' identified by '你的密码'; grant all privileges on *.* to root@'localhost'; 运行这两句sql语句后试下
运行了第一个语句提示是Operation CREATE USER failed for 'root'@'localhos
运行了第一个语句提示是Operation CREATE USER failed for 'root'@'localhos
运行了第一个语句提示是Operation CREATE USER failed for 'root'@'localhos
root用户的密码YES无效。看代码:
ublic DatabaseConn() throws Exception{
DBDRIVER = "com.mysql.jdbc.Driver";
DBURL = "jdbc:mysql://localhost:3306/bms?useUnicode=true&characterEncoding=gbk";
DBUSER = "root";
DBPASS = "xiaoluo1370";
}root用户的密码是xiaoluo1370.YES从哪来的,哪个是正确的代码,从这里入手看看。
private static final String DRIVER_URL="jdbc:mysql://localhost/bms";
private static final String DRIVER_USER="root";
private static final String DRIVER_PASSWORD="xiaoluo1370";
/**
* 打开数据连接
* @return
*/
public static Connection OpenConn()
{
Connection conn=null;
try {
Class.forName(DRIVER_CLASS);
conn=DriverManager.getConnection(DRIVER_URL, DRIVER_USER, DRIVER_PASSWORD);
} catch (ClassNotFoundException e) {
// TODO: handle exception
System.err.println("驱动库加载失败:"+ e.getMessage());
}catch (SQLException e) {
// TODO: handle exception
System.err.println("数据库连接失败:"+ e.getMessage());
}
return conn;
}
骚年 是不是忘记勾选了
骚年 是不是忘记勾选了
骚年 是不是忘记勾选了
create user 'root'@'localhost' identified by '你的密码';
grant all privileges on *.* to root@'localhost';
运行这两句sql语句后试下
create user 'root'@'localhost' identified by '你的密码';
grant all privileges on *.* to root@'localhost';
运行这两句sql语句后试下
详情请猛点这里:http://jingyan.baidu.com/article/f79b7cb35c0f439144023e38.html
1:用户名密码错误
2:没有远程访问权限
详情请猛点这里:http://jingyan.baidu.com/article/f79b7cb35c0f439144023e38.html可是我的其他工程都可以连上数据库啊
详情请猛点这里:http://jingyan.baidu.com/article/f79b7cb35c0f439144023e38.html可是我的其他工程都可以连上数据库啊
其他工程是web工程还是普通java工程?
http://bbs.csdn.net/topics/390363565
详情请猛点这里:http://jingyan.baidu.com/article/f79b7cb35c0f439144023e38.html可是我的其他工程都可以连上数据库啊
其他工程是web工程还是普通java工程?web工程啊,我想是不是数据库的操作代码有问题
过两天吧,回去准备考试; 工作还行吧,现在闲了,天天在学习Android;环境其实挺不错的,对什么都比较随意;