java.sql.SQLException: Access denied for user
java.sql.SQLException: Access denied for user 'root,password=www.linuxidc.com'@'localhost' (using password: NO)
今天自己试着写了下连接数据库的代码的时候出现一个问题,整了半天才发现错误的原因
String driver="com.mysql.jdbc.Driver";
String url ="jdbc:mysql://localhost:3306/paper?user=root,password=www.linuxidc.com";
Class.forName(driver);
this.connection=DriverManager.getConnection(url);
这段代码有一处出现了错误“user=root,password=www.linuxidc.com”这里不能用“,”连接而是用“&”,默认的“&”符合用来分隔用户名和密码的。
其实我想了下,这个还有一种写法不容易出错:DriverManager.getConnection(url,user,password);这个方法把他们分开写。
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号