#使用JDBC连接数据库所产生的问题
1, 添加 “?serverTimezone=UTC”
时区不同,无法访问、
UTC,世界统一的时间
程序报错:
The server time zone value ‘Öйú±ê׼ʱ¼ä’ is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.
样式:jdbc:mysql://localhost:3306/db?serverTimezone=UTC
2,添加“&useSSL=false”
MySQL在高版本需要指明是否进行SSL连接
true 需要连接
false 不需要连接
程序报错:
javax.net.ssl.SSLException: closing inbound before receiving peer’s close_notify
样式:jdbc:mysql://localhost:3306/db?serverTimezone=UTC&useSSL=false
3,“com.mysql.jdbc.Driver"修改为"com.mysql.cj.jdbc.Driver”
原因:最新版MySQL的jdbc驱动包名(路径)引发的问题
程序报错:
Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.