ds.setPoolPreparedStatements( Boolean.valueOf( value ) );
@PostConstruct public void init() { BasicDataSource ds = new BasicDataSource(); ds.setDriverClassName(JDBC_DRIVER_NAME); ds.setUrl("jdbc:derby:" + NACOS_HOME + File.separator + DERBY_BASE_DIR + ";create=true"); ds.setUsername(USER_NAME); ds.setPassword(PASSWORD); ds.setInitialSize(20); ds.setMaxActive(30); ds.setMaxIdle(50); ds.setMaxWait(10000L); ds.setPoolPreparedStatements(true); ds.setTimeBetweenEvictionRunsMillis(TimeUnit.MINUTES .toMillis(10L)); ds.setTestWhileIdle(true); jt = new JdbcTemplate(); jt.setMaxRows(50000); jt.setQueryTimeout(5000); jt.setDataSource(ds); DataSourceTransactionManager tm = new DataSourceTransactionManager(); tjt = new TransactionTemplate(tm); tm.setDataSource(ds); tjt.setTimeout(5000); if (STANDALONE_MODE && !propertyUtil.isStandaloneUseMysql()) { reload(); } }
dataSource.setPoolPreparedStatements(true); dataSource.setPoolPreparedStatements(false);
bds.setUsername(user); bds.setUrl(olap4jDriverConnectionString); bds.setPoolPreparedStatements(false); bds.setMaxIdle(maxPerUserConnectionCount); bds.setMaxActive(maxPerUserConnectionCount);
@Override public synchronized void setPoolPreparedStatements(boolean poolingStatements) { delegate.setPoolPreparedStatements(poolingStatements); }
protected DataSource createDataSource(Map params, SQLDialect dialect) throws IOException { BasicDataSource dataSource = new BasicDataSource(); dataSource.setUrl(getJDBCUrl(params)); String username = (String) USER.lookUp(params); if (username != null) { dataSource.setUsername(username); } String password = (String) PASSWD.lookUp(params); if (password != null) { dataSource.setPassword(password); } dataSource.setDriverClassName("org.h2.Driver"); dataSource.setPoolPreparedStatements(false); return new DBCPDataSource(dataSource); }
/** * Creates a data source by reading properties from a file called 'db.properties', located * paralell to the test setup instance. */ protected DataSource createDataSource() throws IOException { Properties db = fixture; BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName(db.getProperty("driver")); dataSource.setUrl(db.getProperty("url")); if (db.containsKey("user")) { dataSource.setUsername(db.getProperty("user")); } else if (db.containsKey("username")) { dataSource.setUsername(db.getProperty("username")); } if (db.containsKey("password")) { dataSource.setPassword(db.getProperty("password")); } dataSource.setPoolPreparedStatements(true); dataSource.setAccessToUnderlyingConnectionAllowed(true); dataSource.setMinIdle(1); dataSource.setMaxActive(4); // if we cannot get a connection within 5 seconds give up dataSource.setMaxWait(5000); initializeDataSource(dataSource, db); // return a closeable data source (DisposableDataSource interface) // so that the connection pool will be tore down on datastore dispose return new DBCPDataSource(dataSource); }
dataSource.setPoolPreparedStatements(true); dataSource.setMaxOpenPreparedStatements(10);
@ManagedAttribute @Description("Set the prepared statement pooling for this pool.") public void setPoolPreparedStatements(final boolean pool) { ds.setPoolPreparedStatements(pool); }
dataSource.setPoolPreparedStatements(true); dataSource.setPoolPreparedStatements(false);
@PostConstruct public void initDataSource() throws Exception { // 读取jdbc.properties配置, 加载数据源 Properties props = ResourceUtils.getResourceAsProperties("jdbc.properties"); BasicDataSource ds = new BasicDataSource(); ds.setDriverClassName(JDBC_DRIVER_NAME); ds.setUrl(ensurePropValueNotNull(props.getProperty("db.url"))); ds.setUsername(ensurePropValueNotNull(props.getProperty("db.user"))); ds.setPassword(ensurePropValueNotNull(props.getProperty("db.password"))); ds.setInitialSize(Integer.parseInt(ensurePropValueNotNull(props.getProperty("db.initialSize")))); ds.setMaxActive(Integer.parseInt(ensurePropValueNotNull(props.getProperty("db.maxActive")))); ds.setMaxIdle(Integer.parseInt(ensurePropValueNotNull(props.getProperty("db.maxIdle")))); ds.setMaxWait(Long.parseLong(ensurePropValueNotNull(props.getProperty("db.maxWait")))); ds.setPoolPreparedStatements(Boolean.parseBoolean(ensurePropValueNotNull(props .getProperty("db.poolPreparedStatements")))); this.jt = new JdbcTemplate(); this.jt.setDataSource(ds); // 设置最大记录数,防止内存膨胀 this.jt.setMaxRows(MAX_ROWS); // 设置JDBC执行超时时间 this.jt.setQueryTimeout(QUERY_TIMEOUT); }
/** * Prepares a simple data source for the embedded H2 * * @param cacheDirFinder * @return * @throws ConfigurationException */ private DataSource getH2DataSource(DefaultStorageFinder cacheDirFinder) throws ConfigurationException { File storeDirectory = new File(cacheDirFinder.getDefaultPath(), "diskquota_page_store_h2"); storeDirectory.mkdirs(); BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName("org.h2.Driver"); String database = new File(storeDirectory, "diskquota").getAbsolutePath(); dataSource.setUrl("jdbc:h2:" + database); dataSource.setUsername("sa"); dataSource.setPoolPreparedStatements(true); dataSource.setAccessToUnderlyingConnectionAllowed(true); dataSource.setMinIdle(1); dataSource.setMaxActive(-1); // boundless dataSource.setMaxWait(5000); return dataSource; }
dataSource.setPoolPreparedStatements(false);
@PostConstruct public void init() { BasicDataSource ds = new BasicDataSource(); ds.setDriverClassName(JDBC_DRIVER_NAME); ds.setUrl("jdbc:derby:" + NACOS_HOME + File.separator + DERBY_BASE_DIR + ";create=true"); ds.setUsername(USER_NAME); ds.setPassword(PASSWORD); ds.setInitialSize(20); ds.setMaxActive(30); ds.setMaxIdle(50); ds.setMaxWait(10000L); ds.setPoolPreparedStatements(true); ds.setTimeBetweenEvictionRunsMillis(TimeUnit.MINUTES .toMillis(10L)); ds.setTestWhileIdle(true); jt = new JdbcTemplate(); jt.setMaxRows(50000); jt.setQueryTimeout(5000); jt.setDataSource(ds); DataSourceTransactionManager tm = new DataSourceTransactionManager(); tjt = new TransactionTemplate(tm); tm.setDataSource(ds); tjt.setTimeout(5000); if (STANDALONE_MODE && !propertyUtil.isStandaloneUseMysql()) { reload(); } }
dataSource.setUsername(username); dataSource.setPassword(password); dataSource.setPoolPreparedStatements(true); dataSource.setMaxActive(-1); dataSource.setMaxIdle(32);
bds.setUsername(cp.getUsername()); bds.setPassword(cp.getPassword()); bds.setPoolPreparedStatements(true); bds.setMaxOpenPreparedStatements(cp.getMaxOpenPreparedStatements()); bds.setMinIdle(cp.getMinConnections());
ds.setValidationQuery(guessValidationQuery(url)); ds.setAccessToUnderlyingConnectionAllowed(true); ds.setPoolPreparedStatements(true); ds.setMaxOpenPreparedStatements(-1); // unlimited return ds;
protected BasicDataSource getDataSource() throws IOException, SQLException { BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName(fixtureRule.getFixture().getProperty("driver")); dataSource.setUrl(fixtureRule.getFixture().getProperty("url")); dataSource.setUsername(fixtureRule.getFixture().getProperty("username")); dataSource.setPassword(fixtureRule.getFixture().getProperty("password")); dataSource.setPoolPreparedStatements(true); dataSource.setAccessToUnderlyingConnectionAllowed(true); dataSource.setMinIdle(1); dataSource.setMaxActive(4); // if we cannot get a connection within 5 seconds give up dataSource.setMaxWait(5000); cleanupDatabase(dataSource); return dataSource; }
dataSource.setPoolPreparedStatements(settings.getSettingAsBoolean(LuceneEnvironment.JdbcStore.DataSourceProvider.Dbcp.POOL_PREPARED_STATEMENTS, false));