PooledDataSource pooledDataSource = new PooledDataSource(ReflectUtil.getClassLoader(), jdbcDriver, jdbcUrl, jdbcUsername, jdbcPassword); pooledDataSource.setPoolMaximumActiveConnections(jdbcMaxActiveConnections); pooledDataSource.setPoolMaximumIdleConnections(jdbcMaxIdleConnections); pooledDataSource.setPoolMaximumCheckoutTime(jdbcMaxCheckoutTime); pooledDataSource.setPoolTimeToWait(jdbcMaxWaitTime); pooledDataSource.setPoolPingEnabled(true); if (jdbcPingQuery != null) { pooledDataSource.setPoolPingQuery(jdbcPingQuery); pooledDataSource.setPoolPingConnectionsNotUsedFor(jdbcPingConnectionNotUsedFor); pooledDataSource.setDefaultTransactionIsolationLevel(jdbcDefaultTransactionIsolationLevel); ((PooledDataSource) dataSource).forceCloseAll();
public void close() { if (forceCloseMybatisConnectionPool && dataSource instanceof PooledDataSource) { // ACT-233: connection pool of Ibatis is not properely initialized if this is not called! ((PooledDataSource) dataSource).forceCloseAll(); } }
@Override public Connection getConnection(String username, String password) throws SQLException { return popConnection(username, password).getProxyConnection(); }
public PooledDataSourceFactory() { this.dataSource = new PooledDataSource(); }
/** * Method to see if the connection is usable * * @return True if the connection is usable */ public boolean isValid() { return valid && realConnection != null && dataSource.pingConnection(this); }
public void close() { if (forceCloseMybatisConnectionPool && dataSource instanceof PooledDataSource) { // ACT-233: connection pool of Ibatis is not properely initialized if this is not called! ((PooledDataSource) dataSource).forceCloseAll(); } }
@Override public Connection getConnection(String username, String password) throws SQLException { return popConnection(username, password).getProxyConnection(); }
public boolean isValid() { return valid && realConnection != null && dataSource.pingConnection(this); }
/** * The maximum number of idle connections * * @param poolMaximumIdleConnections The maximum number of idle connections */ public void setPoolMaximumIdleConnections(int poolMaximumIdleConnections) { this.poolMaximumIdleConnections = poolMaximumIdleConnections; forceCloseAll(); }
/** * The maximum number of active connections * * @param poolMaximumActiveConnections The maximum number of active connections */ public void setPoolMaximumActiveConnections(int poolMaximumActiveConnections) { this.poolMaximumActiveConnections = poolMaximumActiveConnections; forceCloseAll(); }
/** * The time to wait before retrying to get a connection * * @param poolTimeToWait The time to wait */ public void setPoolTimeToWait(int poolTimeToWait) { this.poolTimeToWait = poolTimeToWait; forceCloseAll(); }
/** * The query to be used to check a connection * * @param poolPingQuery The query */ public void setPoolPingQuery(String poolPingQuery) { this.poolPingQuery = poolPingQuery; forceCloseAll(); }
/** * If a connection has not been used in this many milliseconds, ping the * database to make sure the connection is still good. * * @param milliseconds the number of milliseconds of inactivity that will trigger a ping */ public void setPoolPingConnectionsNotUsedFor(int milliseconds) { this.poolPingConnectionsNotUsedFor = milliseconds; forceCloseAll(); }
/** * Determines if the ping query should be used. * * @param poolPingEnabled True if we need to check a connection before using it */ public void setPoolPingEnabled(boolean poolPingEnabled) { this.poolPingEnabled = poolPingEnabled; forceCloseAll(); }
public void setPoolMaximumIdleConnections(int poolMaximumIdleConnections) { this.poolMaximumIdleConnections = poolMaximumIdleConnections; forceCloseAll(); }
public void setPoolPingConnectionsNotUsedFor(int milliseconds) { this.poolPingConnectionsNotUsedFor = milliseconds; forceCloseAll(); }
/** * The maximum time a connection can be used before it *may* be * given away again. * * @param poolMaximumCheckoutTime The maximum time */ public void setPoolMaximumCheckoutTime(int poolMaximumCheckoutTime) { this.poolMaximumCheckoutTime = poolMaximumCheckoutTime; forceCloseAll(); }
public void setPoolMaximumCheckoutTime(int poolMaximumCheckoutTime) { this.poolMaximumCheckoutTime = poolMaximumCheckoutTime; forceCloseAll(); }
public void setPoolTimeToWait(int poolTimeToWait) { this.poolTimeToWait = poolTimeToWait; forceCloseAll(); }
public void setPoolPingQuery(String poolPingQuery) { this.poolPingQuery = poolPingQuery; forceCloseAll(); }