当前位置: 首页>>代码示例>>Java>>正文


Java BasicDataSource.setMaxOpenPreparedStatements方法代码示例

本文整理汇总了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;
}
 
开发者ID:drinkwater-io,项目名称:drinkwater-java,代码行数:17,代码来源:DBCPSqlDataStore.java

示例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();
}
 
开发者ID:rwth-acis,项目名称:mobsos-query-visualization,代码行数:27,代码来源:SQLDatabase.java

示例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"));

}
 
开发者ID:techysoul,项目名称:java,代码行数:15,代码来源:DataSource.java

示例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();
}
 
开发者ID:rwth-acis,项目名称:mobsos-data-processing,代码行数:40,代码来源:SQLDatabase.java


注:本文中的org.apache.commons.dbcp2.BasicDataSource.setMaxOpenPreparedStatements方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。