错误1
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.
解决方法:
把 com.mysql.jdbc.Driver 改成 com.mysql.cj.jdbc.Driver
Class.forName("com.mysql.cj.jdbc.Driver"); //固定写法,加载驱动
错误2
Exception in thread “main” java.sql.SQLException: 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.
解决方法:
在MySQL的URL后面加上“?serverTimezone=UTC”
//2.用户信息和url
//useUnicode=true&characterEncoding=utf8&useSSL=true
String url="jdbc:mysql://localhost:3306/jdbcstudy?useUnicode=true&characterEncoding=utf8&useSSL=true&serverTimezone=UTC";
String username="root";
String password="123456";