java web添加mysql过程中遇到的错误及解决办法

时间:2023-03-09 00:39:18
java web添加mysql过程中遇到的错误及解决办法

问题一:遇到提示找不到驱动   com.mysql.jdbc.Driver

起初项目中是导入了mysql-connector-java-5.1.45-bin.jar 包的,但是一直依然报错,最后去官网重新下载

下载地址:https://dev.mysql.com/downloads/file/?id=474257

下载后解压,取出mysql-connector-java-5.1.45-bin.jar 包,放置到java web添加mysql过程中遇到的错误及解决办法

目录下,右键选择jar文件,选择add 到链接库即可。

问题二:一直提示  ERROR 1045 (28000): Access denied for user 'ODBC'@'localhost' (using password: NO)

进入tomcat的bin目录下,

mysql -u root -p  密码             #登录mysql 服务器

java web添加mysql过程中遇到的错误及解决办法

不输入密码(之前没有设置初始密码,这里设置密码一直报错,修改密码也无效,暂时没找到办法),回车

java web添加mysql过程中遇到的错误及解决办法

链接成功!

问题三:ri Dec 11 18:28:21 CST 2015 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.

修改办法:

conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/user_info?useSSL=true",user,password);
添加:useSSL=true即可解决