我在手动配置dbcp时,执行数据库相关的操作时,报错以下:
Fri Aug 28 21:10:19 CST 2020 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.
网上的解决办法是设置useSSL,显然我设置了我在配置文件中设置了这个,但是依然报错,原本的配置文件如下:
dbcpconfig.properties的部分内容如下:
#连接设置
driverClassName=com.mysql.jdbc.Driver
url=jdbc:mysql://localhost:3306/jdbcStudy?
useUnicode=true&characterEncoding=utf8&useSSL=true
后来我改变了一下useSSL的位置。这样就没有报出异常警告了,改变后的配置如下,将useSSL放到url中。
driverClassName=com.mysql.jdbc.Driver
url=jdbc:mysql://localhost:3306/jdbcStudy?useSSL=true
useUnicode=true&characterEncoding=utf8