jdbc8连接mysql数据库

如果根据课本的传统数据进行jdbc8对mysql(包含低版本的)的连接时,会发现连接不上,浪费了我好多时间查其他资料发现以下方法:

这里强烈提醒修改语句       

    Class.forName("com.mysql.cj.jdbc.Driver");

//          Class.forName("com.mysql.jdbc.Driver");
conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/test_demo?useSSL=false&serverTimezone=UTC","root","password");

//            conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test_demo","root","password");

即驱动地址变了,同时进行连接时指定时区等

猜你喜欢

转载自blog.csdn.net/weixin_41620013/article/details/80834657