JDBC连接时出现的两个错误
这两个错误都是因为版本的更新导致的;
错误代码:
package FirstTest;
import java.sql.*;
public class FirstJDBC {
public static void main(String[] args) throws SQLException {
try {
//加载驱动类
Class.forName("com.mysql.jdbc.Driver");
//建立连接
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test.jdbc","root","123456");
System.out.println(con);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
}
错误一:
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'
错误二:
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.
该错误为由系统时间错误引起,只需要在访问数据库时在Url后面加上以下的语句即可:
OLD_URL = "jdbc:mysql://localhost:3306/test.jdbc";
NEW_URL = "jdbc:mysql://localhost:3306/test.jdbc?serverTimezone=GMT%2B8";
JDBC连接时出现的两个错误的更多相关文章
- MySQL 8 连接时出现 1251 和 2059 错误
MySQL 8 连接时出现 1251 和 2059 错误 原因是MySQL 8 改了密码加密算法.1 原来是:mysql_native_password MySQL8 改成了 caching_sha2 ...
- mysql jdbc连接时的小问题java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
这次重新修改老程序时出现了上面的错误,排查过后最终找到问题所在:root帐户默认不开放远程访问权限,所以需要修改一下相关权限. 打开MySQL目录下的my.ini文件(win10默认安装在C:\Pro ...
- JDBC连接执行 MySQL 存储过程报权限错误:User does not have access to metadata required to determine stored procedure parameter types. If rights can not be granted,
国内私募机构九鼎控股打造APP,来就送 20元现金领取地址:http://jdb.jiudingcapital.com/phone.html 内部邀请码:C8E245J (不写邀请码,没有现金送) 国 ...
- 使用jdbc连接上oracle的两种方法
1. 使用thin连接 优点:thin驱动都是纯Java代码,并且使用TCP/IP技术通过java的Socket连接上Oracle数据库,所以thin驱动是与平台无关的,无需安装Oracle客户端,只 ...
- Eclipse通过jdbc连接sqlserver2008数据库的两种方式
数据库登录身份验证方式有两种 其中服务器名称即为安装SQLServer2008的电脑,充当数据库服务器,在笔者这里就是自己的电脑名称. 身份验证方式有两种:windows身份验证和SQLSer ...
- JDBC连接执行MySQL存储过程报权限错误
今天在测试项目的时候 突然就报了一个错出来. User does not have access to metadata required to determine stored procedure ...
- windows远程桌面连接时,显示发生身份验证错误,给函数提供的身份无效
摘自:https://www.landui.com/help/show-7787 初次看到这个错误的时候懵了.访问给的地址一看,发现大概意思是不安全了,微软要更新一下 凭据安全支持提供程序协议 (Cr ...
- JDBC连接执行mysql存储过程报权限错误:User does not have access to metadata required to determine stored procedure parameter types. If rights can not be granted,
分析:JDBC在调用存储过程时不光用户要有execute的权限,还需要对mysql.proc具有访问权限.否则它无法访问metadata 解决方案:给数据库用户赋权,赋执行mysql.proc表的se ...
- JDBC连接时出现的问题总结
java.sql.SQLException: The server time zone value '�й���ʱ��' is unrecognized or represents more tha ...
随机推荐
- Vim编辑器点滴积累
Vim编辑器点滴积累 vim tab键空格数量控制 参考链接 临时:进入VIM,执行: :set tabstop=4 永久:编辑用户目录下.vimrc文件,添加:set tabstop=4 vim 安 ...
- 待办事项App 评测
1. 敬业签 2. Microsoft To-Do(奇妙清单) 3. Evernote 4.one note 5.Google Keep 6.to-do-ist 7.365 日历 8.Any.Do 9 ...
- GLIBC中的库函数fflush究竟做了什么?
目录 目录 1 1. 库函数fflush原型 1 2. FILE结构体 1 3. fflush函数实现 2 4. fclose函数实现 4 附1:强弱函数名 5 附2:属性__visibility__ ...
- [考试]NOIP2015模拟题2
// 此博文为迁移而来,写于2015年7月22日,不代表本人现在的观点与看法.原始地址:http://blog.sina.com.cn/s/blog_6022c4720102w72i.html 1.总 ...
- 牛客NOIP暑期七天营-提高组1
牛客NOIP暑期七天营-提高组1 链接 A 边权可为0就排序建一条链子. 但是边权不为0 除了第一个有0的不行. x连向上一个比他小的数. 期间判断有无解. #include <bits/std ...
- PATA1028 List Sorting
Excel can sort records according to any column. Now you are supposed to imitate this function. Input ...
- makefile通用版本(三)
DIR_INC = ./include DIR_SRC = ./src DIR_OBJ = ./obj DIR_BIN = ./bin DIR_LIB = -Wl,-rpath=/home/exbot ...
- 基于web公交查询系统自我安排进度
这周完成站点信息管理
- 用Python 绘制分布(折线)图
用Python 绘制分布(折线)图,使用的是 plot()函数. 一个简单的例子: # encoding=utf-8 import matplotlib.pyplot as plt from pyla ...
- 记lombok@Data和@Builder一起用无法添加无参构造方法的坑
转自:https://blog.csdn.net/w605283073/article/details/89221853 今天和小伙伴讨论一个mybatis-plus的一个诡异问题,最后定位到原因竟然 ...