JDBC 连接数据库报错
1. 在新版mysql中,url需要这样:
String url = "jdbc:mysql://localhost:3306/world?characterEncoding=utf8&useUnicode=true&useSSL=false&serverTimezone=UTC";
“?”后面的部分不加上去的,会报错。(其中world是数据表名)
2. localhost:3306可以不写。所以也可以这样:
String url = "jdbc:mysql:///mysql?characterEncoding=utf8&useUnicode=true&useSSL=false&serverTimezone=UTC";
最后,感谢万能网友!