List of usage examples for org.apache.commons.dbcp BasicDataSource setMaxOpenPreparedStatements
public synchronized void setMaxOpenPreparedStatements(int maxOpenStatements)
Sets the value of the #maxOpenPreparedStatements property.
Note: this method currently has no effect once the pool has been initialized.
From source file:xbird.util.jdbc.datasource.DbcpDataSourceProvider.java
public DataSource setupDataSource(String connectURI) { // creates DataSource BasicDataSource ds = new BasicDataSource(); // for debugging. if (Settings.isLoggingEnabled) { ds.setAccessToUnderlyingConnectionAllowed(true); }// ww w . j a va2 s. c o m ds.setDriverClassName(DriverClassNameResolver.resolve(Settings.get("xbird.db.kind"))); // sets up DataSource ds.setUrl(connectURI); final String dbuser = Settings.get("xbird.db.user"); final String dbpasswd = Settings.get("xbird.db.passwd"); if (dbuser != null && dbuser.length() != 0) { ds.setUsername(dbuser); ds.setPassword(dbpasswd); } // addtinal settings. final String maxactive = Settings.get("xbird.db.pool.maxactive"); if (maxactive != null) ds.setMaxActive(Integer.parseInt(maxactive)); final String maxidle = Settings.get("xbird.db.pool.maxidle"); if (maxidle != null) ds.setMaxIdle(Integer.parseInt(maxidle)); final String maxwait = Settings.get("xbird.db.pool.maxwait"); ds.setMaxWait(maxwait == null ? DEFAULT_MAXWAIT : Integer.parseInt(maxwait)); ds.setDefaultAutoCommit(true); //ds.setDefaultReadOnly(false); final String initialsize = Settings.get("xbird.db.pool.initialsize"); ds.setInitialSize(initialsize == null ? DEFAULT_INITIAL_POLLSIZE : Integer.parseInt(initialsize)); // sets up for PreparedStatements. ds.setPoolPreparedStatements(true); final String maxOpenPreparedStatements = Settings.get("xbird.db.pool.statement.cache_size"); ds.setMaxOpenPreparedStatements(maxOpenPreparedStatements == null ? MAX_OPEN_PREPARED_STATEMENTS : Integer.parseInt(maxOpenPreparedStatements)); return ds; }