这两个错误都是因为版本的更新导致的;

错误代码:

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连接时出现的两个错误的更多相关文章

  1. MySQL 8 连接时出现 1251 和 2059 错误

    MySQL 8 连接时出现 1251 和 2059 错误 原因是MySQL 8 改了密码加密算法.1 原来是:mysql_native_password MySQL8 改成了 caching_sha2 ...

  2. mysql jdbc连接时的小问题java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)

    这次重新修改老程序时出现了上面的错误,排查过后最终找到问题所在:root帐户默认不开放远程访问权限,所以需要修改一下相关权限. 打开MySQL目录下的my.ini文件(win10默认安装在C:\Pro ...

  3. 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 (不写邀请码,没有现金送) 国 ...

  4. 使用jdbc连接上oracle的两种方法

    1. 使用thin连接 优点:thin驱动都是纯Java代码,并且使用TCP/IP技术通过java的Socket连接上Oracle数据库,所以thin驱动是与平台无关的,无需安装Oracle客户端,只 ...

  5. Eclipse通过jdbc连接sqlserver2008数据库的两种方式

    数据库登录身份验证方式有两种     其中服务器名称即为安装SQLServer2008的电脑,充当数据库服务器,在笔者这里就是自己的电脑名称. 身份验证方式有两种:windows身份验证和SQLSer ...

  6. JDBC连接执行MySQL存储过程报权限错误

    今天在测试项目的时候  突然就报了一个错出来. User does not have access to metadata required to determine stored procedure ...

  7. windows远程桌面连接时,显示发生身份验证错误,给函数提供的身份无效

    摘自:https://www.landui.com/help/show-7787 初次看到这个错误的时候懵了.访问给的地址一看,发现大概意思是不安全了,微软要更新一下 凭据安全支持提供程序协议 (Cr ...

  8. 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 ...

  9. JDBC连接时出现的问题总结

    java.sql.SQLException: The server time zone value '�й���׼ʱ��' is unrecognized or represents more tha ...

随机推荐

  1. 微信小程序 scroll-view 横向滚动条 隐藏无效

    看了许多网上教程说是添加如下样式可以解决,我加入到组件wxss中无效,加入全局wxss生效. 添加css代码如下: ::-webkit-scrollbar { ; ; color: transpare ...

  2. Java 解压 zip 文件

    代码如下 package test_java; import java.io.File; import java.io.FileOutputStream; import java.io.IOExcep ...

  3. 【Activiti学习之五】BPMN事件

    环境 JDK 1.8 MySQL 5.6 Tomcat 7 Eclipse-Luna activiti 6.0 一.事件定义1.定时器事件(1)timeDate:指定时间触发<timerEven ...

  4. c# EPPlus读取Excel里面的时间字段时,1900-01-01转成了1899-12-31

    看到一篇文章:https://bbs.csdn.net/topics/70511379,5楼的回复: 我发现EXCEL有千年虫BUG,把1900年算成闰年了,2月有29天.1900年3月1日以后就没问 ...

  5. 【神经网络与深度学习】neural-style、chainer-fast-neuralstyle图像风格转换使用

    neural-style 官方地址:这个是使用torch7实现的;torch7安装比较麻烦.我这里使用的是大神使用TensorFlow实现的https://github.com/anishathaly ...

  6. 《Linux就该这么学》自学笔记_ch21_使用Git分布式版本控制系统

    <Linux就该这么学>自学笔记_ch21_使用Git分布式版本控制系统 文章主要内容: 分布式版本控制系统 使用Git服务程序 提交数据 移除数据 移动数据 历史记录 还原数据 管理标签 ...

  7. Python 3.X 练习集100题 02

    企业发放的奖金根据利润提成.利润(I):低于或等于10万元时,奖金可提10%:高于10万元,低于20万元时,低于10万元的部分按10%提成,高于10万元的部分,可提成7.5%:20万到40万之间时,高 ...

  8. docker 学习操作记录 1

    记录1 Xshell (Build ) Copyright (c) NetSarang Computer, Inc. All rights reserved. Type `help' to learn ...

  9. unable to find utility "simctl", not a developer tool or in PATH解决方案

    解决方案就是去xcode设置里面,将Command line Tools设置一下,在Xcode>preferences>Locations里面,设置之后再运行终端即可

  10. IScroll中div点击事件触发两次解决办法

    1.网上的同学说的,直接修改源代码,但是这种方法可能会影响到现有的程序. 搜索onBeforeScrollStart方法,将其中的preventDefault禁止掉搜索_end方法,将其中模拟clic ...