为了账号安全,请及时绑定邮箱和手机立即绑定

有没有好心的大神告诉我一下,这是什么原因

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.
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.
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129)
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89)
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:63)
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:73)
    at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:76)
    at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:835)
    at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:455)
    at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:240)
    at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:207)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at com.imooc.DB.DBUtil.main(DBUtil.java:20)
Caused by: com.mysql.cj.exceptions.InvalidConnectionAttributeException: 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.
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:61)
    at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:85)
    at com.mysql.cj.util.TimeUtil.getCanonicalTimezone(TimeUtil.java:132)
    at com.mysql.cj.protocol.a.NativeProtocol.configureTimezone(NativeProtocol.java:2234)
    at com.mysql.cj.protocol.a.NativeProtocol.initServerSession(NativeProtocol.java:2258)
    at com.mysql.cj.jdbc.ConnectionImpl.initializePropsFromServer(ConnectionImpl.java:1319)
    at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:966)
    at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:825)
    ... 6 more

正在回答

5 回答

$val是一个array其中包含很多项

0 回复 有任何疑惑可以回复我~

是时区错了原来。。已解决

0 回复 有任何疑惑可以回复我~
#1

三好学生110

你好,请问是怎么解决的,我也出了这个错java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
2018-12-04 回复 有任何疑惑可以回复我~
#2

qq_慕哥5186556 回复 三好学生110

那个url
2019-02-21 回复 有任何疑惑可以回复我~
#3

幕布斯7482464

请问怎么解决的???
2019-04-02 回复 有任何疑惑可以回复我~

改了一下,现在变成这样了


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.
Exception in thread "main" java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129)
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
    at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
    at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:835)
    at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:455)
    at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:240)
    at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:207)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at com.imooc.DB.DBUtil.main(DBUtil.java:20)


0 回复 有任何疑惑可以回复我~

package com.imooc.DB;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class DBUtil {

    private static final String URL="jdbc:mysql://127.0.0.1:3306/imooc";
    private static final String USER="root";
    private static final String PASSWORD="root";
    
    
    
    public static void main(String[] args) throws Exception{
        //加载驱动程序
        Class.forName("com.mysql.jdbc.Driver");
        //获得数据库连接
        Connection conn=DriverManager.getConnection(URL, USER, PASSWORD);
        //操纵数据库的连接操作数据库,实现增删改查
        Statement stmt=conn.createStatement();
    ResultSet rs=stmt.executeQuery("select user_name,age from imooc_goddess");
    
    while(rs.next()) {
        System.out.println(rs.getString("user_name")+","+rs.getInt("age"));
        
        
    }
    }

}

0 回复 有任何疑惑可以回复我~
#1

qq_慕移动215866 提问者

就是按照老师的步骤一步步来的
2018-11-27 回复 有任何疑惑可以回复我~

你是怎么加载驱动的,还有你的连接怎么写的,发下代码

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

有没有好心的大神告诉我一下,这是什么原因

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信