本文整理汇总了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();
}