當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。