Code example for Connection

Methods: isClosed

0
        if (con == null) {
            try { 
                Class.forName("com.mysql.jdbc.Driver").newInstance();
                con = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/" + dbName + "?autoReconnect=true", dbUser, dbPass);
 
                if (!con.isClosed()) {
                  logger.info("Mysql Connected Successfully..");
                } 
            } catch (Exception e) {
                  logger.error("Mysql not Connected.. : " + e.getMessage());
                e.printStackTrace();
            } 
        } 
        return con;
    } 
}