抛出错误代码
HTTP Status 500 – Internal Server Error
Type Exception Report
Message Request processing failed; nested exception is org.springframework.transaction.CannotCreateTransactionException: Could not open JDBC Connection for transaction; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server.
Description The server encountered an unexpected condition that prevented it from fulfilling the request.
加入库还会报错:
com. mysql. cj. exceptions. SSLParamsException: Cannot open file:
解决办法
第一步:http://central.maven.org/maven2/mysql/mysql-connector-java/
//jdbc所有版本Java的驱动(根据版本选择)
第二步:将网站下载的jdbc 加入到netbeans目录C:\Program Files\NetBeans 8.0\ide\modules\ext(当然在别的文件夹也可以但是不太好找,我给出原来的jdbc存储位置。主要是找你安装的net beans的位置)
第三步:在集成软件中加载入jdbc库,首先加入jdbc 以前的库
然后右键点编辑。
添加你下载的jdbc版本进来就好了,文件路径就是原版的路径哦
C:\Program Files\NetBeans 8.0\ide\modules\ext
第四步:新版的连接方式也有所改动
连接代码基本语句
Class.forName("com.mysql.cj.jdbc.Driver");//增加了cj
String url="jdbc:mysql://localhost:3306/数据库名?useSSL=false&serverTimezone=GMT%2B8&";
Connection conn=DriverManager.getConnection(url,"user","passward");
Statement stmt=conn.createStatement();
然后就解决啦
(如果还不行就重启一下)