- Add the Codota plugin to your IDE and get smart completions
private void myMethod () {DateTime d =
new DateTime()
DateTimeFormatter formatter;String text;formatter.parseDateTime(text)
Object instant;new DateTime(instant)
- Smart code suggestions by Codota
}
public static Connection createConnection(){ String host = Config.dbHost; String user = Config.dbUsername; String password = Config.dbPassword; String dbName = Config.dbName; String url="jdbc:mysql://" + host + ":3306/" + dbName + "?characterEncoding=utf8"; Connection con=null; try{ con = DriverManager.getConnection(url,user,password);//建立mysql的连接 logger.debug("success!"); } catch(MySQLSyntaxErrorException e){ logger.error("数据库不存在..请先手动创建创建数据库:" + dbName); e.printStackTrace(); } catch(SQLException e2){ logger.error("SQLException",e2); } return con; } public static void main(String [] args) throws Exception{
/** * Indicates whether an exception is a result of a particular database or table not * existing in the MySQL instance. Error codes for MySQL can be found here: * http://dev.mysql.com/doc/refman/5.6/en/error-messages-server.html */ public static boolean isDatabaseDoesNotExistException(Exception e) { return e instanceof MySQLSyntaxErrorException && ((MySQLSyntaxErrorException) e).getErrorCode() == MYSQL_DB_DOESNT_EXIST_ERROR_CODE; }
/** * Indicates whether an exception is a result of a particular database * identifier being too long . Error codes for MySQL can be found here: * http://dev.mysql.com/doc/refman/5.6/en/error-messages-server.html */ public static boolean isDatabaseNameTooLongException(Exception e) { return e instanceof MySQLSyntaxErrorException && ((MySQLSyntaxErrorException) e).getErrorCode() == MYSQL_DB_NAME_TOO_LONG_ERROR_CODE; }