今天我打開自己的應用程序,卻收到了一條來自MySQL的錯誤提示,提示我應用程序無法啟動,讓我很是困惑。
Exception in thread "main" com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up. 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.jdbc.Util.handleNewInstance(Util.java:404) at com.mysql.jdbc.Util.getInstance(Util.java:387) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:919) at com.mysql.jdbc. SQLError.createSQLException(SQLError.java:898) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:887) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:861) at com.mysql.jdbc.ConnectionImpl.connectWithRetries(ConnectionImpl.java:2164) at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2089) at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:806) at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47) 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.jdbc.Util.handleNewInstance(Util.java:404) at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:410) at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:328) at java.sql.DriverManager.getConnection(DriverManager.java:664) at java.sql.DriverManager.getConnection(DriverManager.java:247) at App.Connector.createConnection(Connector.java:14) at App.Main.main(Main.java:7) Caused by: java.lang.NullPointerException at com.mysql.jdbc.StreamingResultSet.rowDataPacket(StreamingResultSet.java:1946) at com.mysql.jdbc.StreamingResultSet.buildCachedRows(StreamingResultSet.java:811) at com.mysql.jdbc.StreamingResultSet.populate(StreamingResultSet.java:697) at com.mysql.jdbc.StreamingResultSet.<init>(StreamingResultSet.java:476) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2522) at com.mysql.jdbc.ConnectionImpl.setReadOnlyInternal(ConnectionImpl.java:4854) at com.mysql.jdbc.ConnectionImpl.connectWithRetries(ConnectionImpl.java:2109) ... 15 more
在經過一番搜索之后,我發現這個問題的原因可能是由于MySQL的連接出現問題導致的。因此,我檢查了我的MySQL數據庫并發現它已經在我的電腦上停止提供服務。
為了解決這個問題,我必須重新啟動MySQL服務。經過一番嘗試后,我終于成功地啟動了MySQL服務,并重新啟動了我的應用程序,一切恢復了正常。
上一篇css怎么限制文本數