日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 人文社科 > 生活经验 >内容正文

生活经验

eclipse关闭mysql数据库,有关于用eclipse连接mysql数据库出现的问题以及解决办法

發布時間:2023/11/27 生活经验 20 豆豆
生活随笔 收集整理的這篇文章主要介紹了 eclipse关闭mysql数据库,有关于用eclipse连接mysql数据库出现的问题以及解决办法 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

寫帖子是為了讓更多的程序員減少再調試bug中的時間,也希望大家能一起把自己遇到的錯誤及解決方法寫出來。我是一個剛開始學java的大二學生,用的是《java開發實戰經典》。在寫p646的程序中一直報錯。特貼出來

先把代碼發出來

public class ConnectionDemo02 {

//定義MySql的數據庫驅動程序

public static final String DBDRIVER="com.mysql.jdbc.Driver";? ?//錯誤,應改為com.mysql.cj.jdbc.Driver

//定義MySql數據庫的鏈接地址

public static final String DBURL="jdbc:mysql://localhost:3306/mldn";

//錯誤,應該改為:jdbc:mysql://localhost:3306/mldn?useSSL=false&serverTimezone=GMT";//定義MySql數據庫的連接用戶名

public static final String DBUSER="root";

//定義MySql數據庫的連接密碼

public static final String DBPASS="12315";

public static void main(String[] args)

{

Connection conn=null;

try

{

Class.forName(DBDRIVER);

}catch(ClassNotFoundException e)

{

e.printStackTrace();

}

try

{

conn=DriverManager.getConnection(DBURL, DBUSER, DBPASS);

}catch(SQLException e)

{

e.printStackTrace();

}

System.out.println(conn);

try

{

conn.close();

}catch(SQLException 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.

Sat May 05 09:24:57 GMT+08:00 2018 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.

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:127)

at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:95)

at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:87)

at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:61)

at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:71)

at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:76)

at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:862)

at com.mysql.cj.jdbc.ConnectionImpl.(ConnectionImpl.java:444)

at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:230)

at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:226)

at java.sql.DriverManager.getConnection(DriverManager.java:664)

at java.sql.DriverManager.getConnection(DriverManager.java:247)

at 連接數據庫.ConnectionDemo02.main(ConnectionDemo02.java:28)

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(NativeConstructorAccessorImpl.java:62)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

at java.lang.reflect.Constructor.newInstance(Constructor.java:423)

at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:59)

at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:83)

at com.mysql.cj.util.TimeUtil.getCanonicalTimezone(TimeUtil.java:128)

at com.mysql.cj.protocol.a.NativeProtocol.configureTimezone(NativeProtocol.java:2201)

at com.mysql.cj.protocol.a.NativeProtocol.initServerSession(NativeProtocol.java:2225)

at com.mysql.cj.jdbc.ConnectionImpl.initializePropsFromServer(ConnectionImpl.java:1391)

at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:993)

at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:852)

... 6 more

null

Exception in thread "main" java.lang.NullPointerException

at 連接數據庫.ConnectionDemo02.main(ConnectionDemo02.java:36)改正方法在原碼有

總結

以上是生活随笔為你收集整理的eclipse关闭mysql数据库,有关于用eclipse连接mysql数据库出现的问题以及解决办法的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。