List of utility methods to do JDBC Connection Pool
Connection | getConnection() Helper method to get a connection from the connection pool. if (!driverSetup) { throw new Exception("Driver has not been set up with a call to setupDriver()."); return DriverManager.getConnection("jdbc:apache:commons:dbcp:local"); |
Connection | getConnectionFromPool() Returns a connection from the previous configurePool the pool try { return DriverManager.getConnection(POOL_DRIVER_URL + POOL_NAME); } catch (SQLException e) { throw new RuntimeException(e); |
Connection | getDatabaseConnection(String propertiesFile) get Database Connection Properties properties = new Properties(); properties.load(new FileInputStream(propertiesFile)); String jdbcClassName = properties.getProperty("jdbc.class.name"); String jdbcDatabase = properties.getProperty("jdbc.database"); String jdbcUsername = properties.getProperty("jdbc.username"); String jdbcPassword = properties.getProperty("jdbc.password"); Class.forName(jdbcClassName); return DriverManager.getConnection(jdbcDatabase, jdbcUsername, jdbcPassword); ... |