本文整理匯總了Java中org.apache.commons.dbcp2.BasicDataSource.setMaxOpenPreparedStatements方法的典型用法代碼示例。如果您正苦於以下問題:Java BasicDataSource.setMaxOpenPreparedStatements方法的具體用法?Java BasicDataSource.setMaxOpenPreparedStatements怎麽用?Java BasicDataSource.setMaxOpenPreparedStatements使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.dbcp2.BasicDataSource
的用法示例。
在下文中一共展示了BasicDataSource.setMaxOpenPreparedStatements方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getBasicDataSource
import org.apache.commons.dbcp2.BasicDataSource; //導入方法依賴的package包/類
private static BasicDataSource getBasicDataSource(DatasourceConfiguration configuration) {
BasicDataSource dbcpDataSource = new BasicDataSource();
dbcpDataSource.setDriverClassName(configuration.getDriverClassname());
dbcpDataSource.setUrl(configuration.getUrl());
dbcpDataSource.setUsername(configuration.getUser());
dbcpDataSource.setPassword(configuration.getPassword());
// Enable statement caching (Optional)
dbcpDataSource.setPoolPreparedStatements(true);
dbcpDataSource.setValidationQuery("Select 1 ");
dbcpDataSource.setMaxOpenPreparedStatements(50);
dbcpDataSource.setLifo(true);
dbcpDataSource.setMaxTotal(10);
dbcpDataSource.setInitialSize(2);
return dbcpDataSource;
}
示例2: SQLDatabase
import org.apache.commons.dbcp2.BasicDataSource; //導入方法依賴的package包/類
public SQLDatabase(SQLDatabaseType jdbcInfo, String username, String password, String database, String host,
int port, String key) {
// TODO: check parameters
this.jdbcInfo = jdbcInfo;
this.username = username;
this.password = password;
this.host = host;
this.port = port;
this.database = database;
this.key = key;
BasicDataSource ds = new BasicDataSource();
String urlPrefix = jdbcInfo.getJDBCurl(this.host, this.database, this.port) + "?autoReconnect=true";
ds.setUrl(urlPrefix);
ds.setUsername(username);
ds.setPassword(password);
ds.setDriverClassName(jdbcInfo.getDriverName());
ds.setMinIdle(5);
ds.setMaxIdle(10);
ds.setMaxOpenPreparedStatements(100);
dataSource = ds;
setValidationQuery();
}
示例3: DataSource
import org.apache.commons.dbcp2.BasicDataSource; //導入方法依賴的package包/類
private DataSource() throws IOException, SQLException, PropertyVetoException {
LOGGER.info("Creating datasource instance..");
basicDataSource = new BasicDataSource();
basicDataSource.setDriverClassName(CONFIG.get("DB_DRIVER_CLASS_NAME"));
basicDataSource.setUsername(CONFIG.get("DB_USER_NAME"));
basicDataSource.setPassword(CONFIG.get("DB_PASSWORD"));
basicDataSource.setUrl(CONFIG.get("DB_URL"));
// the settings below are optional -- dbcp can work with defaults
basicDataSource.setMinIdle(CONFIG.getInt("DB_MIN_IDLE"));
basicDataSource.setMaxIdle(CONFIG.getInt("DB_MAX_IDLE"));
basicDataSource.setMaxOpenPreparedStatements(CONFIG.getInt("DB_MAX_OPEN_PS"));
}
示例4: SQLDatabase
import org.apache.commons.dbcp2.BasicDataSource; //導入方法依賴的package包/類
/**
*
* Constructor for a database instance.
*
* @param jdbcInfo the driver you are using
* @param username login name
* @param password password
* @param database database name
* @param host host for the connection
* @param port port of the SQL server
*
*/
public SQLDatabase(SQLDatabaseType jdbcInfo, String username, String password, String database, String host,
int port) {
this.jdbcInfo = jdbcInfo;
this.username = username;
this.password = password;
this.host = host;
this.port = port;
this.database = database;
BasicDataSource ds = new BasicDataSource();
String urlPrefix = jdbcInfo.getURLPrefix(this.host, this.database, this.port)
+ "?autoReconnect=true&useSSL=false&serverTimezone=UTC";
ds.setUrl(urlPrefix);
ds.setUsername(username);
ds.setPassword(password);
ds.setDriverClassName(jdbcInfo.getDriverName());
ds.setPoolPreparedStatements(true);
ds.setTestOnBorrow(true);
ds.setRemoveAbandonedOnBorrow(true);
ds.setRemoveAbandonedOnMaintenance(true);
ds.setMaxOpenPreparedStatements(100);
ds.setMaxConnLifetimeMillis(1000 * 60 * 60);
dataSource = ds;
setValidationQuery();
}