简体   繁体   English

.MySQLNonTransientConnectionException: Could not create connection to database server

[英].MySQLNonTransientConnectionException: Could not create connection to database server

Getting Error For the Following Code

  package jdbcdrive;

import java.sql.*;
public class Lpt {

    /**
     * @param args
     * @throws SQLException
     */
    public static void main(String[] args) throws SQLException {

        Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/lpt?autoReconnect=true&useSSL=false","root","2664");

        Statement st = con.createStatement();

        ResultSet rs = st.executeQuery("SELECT * FROM sys.lpt");

        while(rs.next()) {

            System.out.println(rs.getInt("BatchName")+" "+rs.getString("StudentName")+" "+rs.getString("StudentName")+" "+rs.getString("studentMobileNo")+" "+rs.getString("Address"));
        }

    }

}

The Output Error I'm getting is

Exception in thread "main" com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.

Try adding this to your connection String:

"useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC" 

it worked for me

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException:无法创建与数据库服务器的连接 - com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server MySQLNonTransientConnectionException 无法创建与数据库服务器的连接。 引起:java.lang.NullPointerException - MySQLNonTransientConnectionException Could not create connection to database server. Caused by: java.lang.NullPointerException Apache Solr/JDBC/MySQL.Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server - Apache Solr/JDBC/MySQL.Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server 春季启动:MySQLNonTransientConnectionException:无法创建连接 - Spring boot : MySQLNonTransientConnectionException: Could not create connection 登录中的异常::无法创建与数据库服务器的连接 - Exception in Login:: Could not create connection to database server 无法通过 Docker 创建与数据库服务器的连接 - Could not create connection to database server via Docker 无法创建与数据库服务器MySQL 8.0的连接 - Could not create connection to database server, MySQL 8.0 异常无法创建与数据库服务器的连接 - exception could not create connection to database server 无法创建到 MySQL 数据库服务器的 JDBC 连接 - Could not create JDBC connection to MySQL database server “无法创建与数据库服务器的连接” netbeans谷歌云sql错误 - “Could not create connection to database server” netbeans google cloud sql error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM