@Test public void testInit () throws IOException, SQLException { MySQLConfig mySQLConfig = createConfig(); Database.init(mySQLConfig); assertNotNull(Database.getDataSource()); assertNotNull(Database.getConnection()); Database.close(); }
public static void init (MySQLConfig mySQLConfig) { LocalLogger.print("connect to mysql database: " + mySQLConfig.getJDBCUrl()); HikariConfig config = new HikariConfig(); config.setJdbcUrl(mySQLConfig.getJDBCUrl()); config.setUsername(mySQLConfig.getUser()); config.setPassword(mySQLConfig.getPassword()); config.addDataSourceProperty("cachePrepStmts", "true"); config.addDataSourceProperty("prepStmtCacheSize", "" + mySQLConfig.getPrepStmtCacheSize()); config.addDataSourceProperty("prepStmtCacheSqlLimit", "" + mySQLConfig.getPrepStmtCacheSqlLimit()); config.addDataSourceProperty("useServerPrepStmts", "true"); config.addDataSourceProperty("useLocalSessionState", "true"); config.addDataSourceProperty("rewriteBatchedStatements", "true"); config.addDataSourceProperty("cacheResultSetMetadata", "true"); config.addDataSourceProperty("cacheServerConfiguration", "true"); config.addDataSourceProperty("maintainTimeStats", "false"); dataSource = new HikariDataSource(config); LocalLogger.print("Connection established."); }
Database { public static void init (MySQLConfig mySQLConfig) { LocalLogger.print("connect to mysql database: " + mySQLConfig.getJDBCUrl()); HikariConfig config = new HikariConfig(); config.setJdbcUrl(mySQLConfig.getJDBCUrl()); config.setUsername(mySQLConfig.getUser()); config.setPassword(mySQLConfig.getPassword()); config.addDataSourceProperty("cachePrepStmts", "true"); config.addDataSourceProperty("prepStmtCacheSize", "" + mySQLConfig.getPrepStmtCacheSize()); config.addDataSourceProperty("prepStmtCacheSqlLimit", "" + mySQLConfig.getPrepStmtCacheSqlLimit()); config.addDataSourceProperty("useServerPrepStmts", "true"); config.addDataSourceProperty("useLocalSessionState", "true"); config.addDataSourceProperty("rewriteBatchedStatements", "true"); config.addDataSourceProperty("cacheResultSetMetadata", "true"); config.addDataSourceProperty("cacheServerConfiguration", "true"); config.addDataSourceProperty("maintainTimeStats", "false"); dataSource = new HikariDataSource(config); LocalLogger.print("Connection established."); } }
Database { public static void init (MySQLConfig mySQLConfig) { LocalLogger.print("connect to mysql database: " + mySQLConfig.getJDBCUrl()); HikariConfig config = new HikariConfig(); config.setJdbcUrl(mySQLConfig.getJDBCUrl()); config.setUsername(mySQLConfig.getUser()); config.setPassword(mySQLConfig.getPassword()); config.addDataSourceProperty("cachePrepStmts", "true"); config.addDataSourceProperty("prepStmtCacheSize", "" + mySQLConfig.getPrepStmtCacheSize()); config.addDataSourceProperty("prepStmtCacheSqlLimit", "" + mySQLConfig.getPrepStmtCacheSqlLimit()); config.addDataSourceProperty("useServerPrepStmts", "true"); config.addDataSourceProperty("useLocalSessionState", "true"); config.addDataSourceProperty("rewriteBatchedStatements", "true"); config.addDataSourceProperty("cacheResultSetMetadata", "true"); config.addDataSourceProperty("cacheServerConfiguration", "true"); config.addDataSourceProperty("maintainTimeStats", "false"); dataSource = new HikariDataSource(config); LocalLogger.print("Connection established."); } protected  Database(); }
Database { public static void init (MySQLConfig mySQLConfig) { LocalLogger.print("connect to mysql database: " + mySQLConfig.getJDBCUrl()); HikariConfig config = new HikariConfig(); config.setJdbcUrl(mySQLConfig.getJDBCUrl()); config.setUsername(mySQLConfig.getUser()); config.setPassword(mySQLConfig.getPassword()); config.addDataSourceProperty("cachePrepStmts", "true"); config.addDataSourceProperty("prepStmtCacheSize", "" + mySQLConfig.getPrepStmtCacheSize()); config.addDataSourceProperty("prepStmtCacheSqlLimit", "" + mySQLConfig.getPrepStmtCacheSqlLimit()); config.addDataSourceProperty("useServerPrepStmts", "true"); config.addDataSourceProperty("useLocalSessionState", "true"); config.addDataSourceProperty("rewriteBatchedStatements", "true"); config.addDataSourceProperty("cacheResultSetMetadata", "true"); config.addDataSourceProperty("cacheServerConfiguration", "true"); config.addDataSourceProperty("maintainTimeStats", "false"); dataSource = new HikariDataSource(config); LocalLogger.print("Connection established."); } protected  Database(); static void init(MySQLConfig mySQLConfig); static HikariDataSource getDataSource(); static Connection getConnection(); static void close(); }
Database { public static void init (MySQLConfig mySQLConfig) { LocalLogger.print("connect to mysql database: " + mySQLConfig.getJDBCUrl()); HikariConfig config = new HikariConfig(); config.setJdbcUrl(mySQLConfig.getJDBCUrl()); config.setUsername(mySQLConfig.getUser()); config.setPassword(mySQLConfig.getPassword()); config.addDataSourceProperty("cachePrepStmts", "true"); config.addDataSourceProperty("prepStmtCacheSize", "" + mySQLConfig.getPrepStmtCacheSize()); config.addDataSourceProperty("prepStmtCacheSqlLimit", "" + mySQLConfig.getPrepStmtCacheSqlLimit()); config.addDataSourceProperty("useServerPrepStmts", "true"); config.addDataSourceProperty("useLocalSessionState", "true"); config.addDataSourceProperty("rewriteBatchedStatements", "true"); config.addDataSourceProperty("cacheResultSetMetadata", "true"); config.addDataSourceProperty("cacheServerConfiguration", "true"); config.addDataSourceProperty("maintainTimeStats", "false"); dataSource = new HikariDataSource(config); LocalLogger.print("Connection established."); } protected  Database(); static void init(MySQLConfig mySQLConfig); static HikariDataSource getDataSource(); static Connection getConnection(); static void close();  }