Refine search
@Override public DataSource create(Configuration hdpConfig) throws SQLException { LOG.debug("Creating BoneCP connection pool for the MetaStore"); String driverUrl = DataSourceProvider.getMetastoreJdbcDriverUrl(hdpConfig); String user = DataSourceProvider.getMetastoreJdbcUser(hdpConfig); String passwd = DataSourceProvider.getMetastoreJdbcPasswd(hdpConfig); int maxPoolSize = MetastoreConf.getIntVar(hdpConfig, MetastoreConf.ConfVars.CONNECTION_POOLING_MAX_CONNECTIONS); Properties properties = DataSourceProvider.getPrefixedProperties(hdpConfig, BONECP); long connectionTimeout = hdpConfig.getLong(CONNECTION_TIMEOUT_PROPERTY, 30000L); String partitionCount = properties.getProperty(PARTITION_COUNT_PROPERTY, "1"); BoneCPConfig config = null; try { config = new BoneCPConfig(properties); } catch (Exception e) { throw new SQLException("Cannot create BoneCP configuration: ", e); } config.setJdbcUrl(driverUrl); // if we are waiting for connection for a long time, something is really wrong // better raise an error than hang forever // see DefaultConnectionStrategy.getConnectionInternal() config.setConnectionTimeoutInMs(connectionTimeout); config.setMaxConnectionsPerPartition(maxPoolSize); config.setPartitionCount(Integer.parseInt(partitionCount)); config.setUser(user); config.setPassword(passwd); return initMetrics(new BoneCPDataSource(config)); }
public JDBCManager(String driver, String connectionUri, int nConnectionsPool, String userName, String password) throws SQLException, ClassNotFoundException { Class.forName(driver); BoneCPConfig config = new BoneCPConfig(); config.setJdbcUrl(connectionUri); config.setMinConnectionsPerPartition(nConnectionsPool); config.setMaxConnectionsPerPartition(nConnectionsPool); config.setUsername(userName); config.setPassword(password); config.setPartitionCount(1); config.setDefaultAutoCommit(false); connectionPool = new BoneCP(config); // setup the connection pool }
@Override public DBI get() { final BoneCPConfig dbConfig = new BoneCPConfig(); dbConfig.setJdbcUrl(config.getJdbcUrl()); dbConfig.setUsername(config.getUsername()); dbConfig.setPassword(config.getPassword()); dbConfig.setMinConnectionsPerPartition(config.getMinIdle()); dbConfig.setMaxConnectionsPerPartition(config.getMaxActive()); dbConfig.setConnectionTimeout(config.getConnectionTimeout().getPeriod(), config.getConnectionTimeout().getUnit()); dbConfig.setIdleMaxAge(config.getIdleMaxAge().getPeriod(), config.getIdleMaxAge().getUnit()); dbConfig.setMaxConnectionAge(config.getMaxConnectionAge().getPeriod(), config.getMaxConnectionAge().getUnit()); dbConfig.setIdleConnectionTestPeriod(config.getIdleConnectionTestPeriod().getPeriod(), config.getIdleConnectionTestPeriod().getUnit()); dbConfig.setPartitionCount(1); dbConfig.setDefaultTransactionIsolation("READ_COMMITTED"); dbConfig.setDisableJMX(false);
private DataSource getBoneCPDatSource() { final BoneCPConfig dbConfig = new BoneCPConfig(); dbConfig.setJdbcUrl(config.getJdbcUrl()); dbConfig.setUsername(config.getUsername()); dbConfig.setPassword(config.getPassword()); dbConfig.setMinConnectionsPerPartition(config.getMinIdle()); dbConfig.setMaxConnectionsPerPartition(config.getMaxActive()); dbConfig.setConnectionTimeout(config.getConnectionTimeout().getPeriod(), config.getConnectionTimeout().getUnit()); /* dbConfig.setIdleMaxAge(config.getIdleMaxAge().getPeriod(), config.getIdleMaxAge().getUnit()); dbConfig.setMaxConnectionAge(config.getMaxConnectionAge().getPeriod(), config.getMaxConnectionAge().getUnit()); dbConfig.setIdleConnectionTestPeriod(config.getIdleConnectionTestPeriod().getPeriod(), config.getIdleConnectionTestPeriod().getUnit()); */ dbConfig.setPartitionCount(1); dbConfig.setDisableJMX(false); return new BoneCPDataSource(dbConfig); }
public DataSource dataSource() throws SQLException, PropertyVetoException { BoneCPConfig config = new BoneCPConfig(); config.setUsername(""); config.setPassword(""); config.setJdbcUrl("jdbc:derby:C:\\Users\\Kevin\\Desktop\\DerbyDB"); BoneCPDataSource dataSource = new BoneCPDataSource(config); dataSource.setDriverClass("org.apache.derby.jdbc.EmbeddedDriver"); return dataSource; }
if (size >= 0) ds.setStatementsCacheSize(size); if (size >= 0) ds.setMaxConnectionsPerPartition(size); if (size >= 0) ds.setMinConnectionsPerPartition(size); if (value > 0) ds.setIdleMaxAge(value); ds.setJdbcUrl(dbURL); ds.setUsername(dbUser); ds.setPassword(dbPassword);
public JDBCConnectionPool(final String jdbcString, final int numberOfConnection) throws SQLException { super(); this.numberOfConnection = numberOfConnection; this.jdbcString = jdbcString; BoneCPConfig config = new BoneCPConfig(); config.setJdbcUrl(jdbcString); this.connectionPool = new BoneCP(config); this.connectionSession = new HashMap<String, Connection>(); }
config = new BoneCPConfig("bonecp-config.xml"); } catch (Exception e) { e.printStackTrace(); connectionPool = new BoneCP(config); // setup the connection pool connection = connectionPool.getConnection(); // fetch a connectionPool.shutdown(); // shutdown connection pool. } catch (SQLException e) { e.printStackTrace();
BoneCPConfig config = new BoneCPConfig(); config.setJdbcUrl("jdbc:hsqldb:mem:test_common;shutDown=false"); config.setUsername("sa"); config.setPassword(""); JdbcTemplate dataSource = new BoneCPDataSource(config); jdbcTemplate = new JdbcTemplate(dataSource); //If you are using named queries NamedParameterJdbcTemplate namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(dataSource); //create necessary tables etc here. setupDb(jdbcTemplate); SomeBean anotherBean = new SomeBean(); YourDAO dao = new YourDAOImpl(); dao.setNamedJdbcTemplate(namedParameterJdbcTemplate); dao.setSomeOtherBean(anotherBean); //Mimic spring container if you implement InitialzingBean dao.afterPropertiesSet();
BoneCPConfig config = new BoneCPConfig(); config.setJdbcUrl("jdbc:mysql://" + MYSQL_HOST_NAME + "/" + MYSQL_BASE_NAME + "?user=" + MYSQL_LOGIN + "&password=" + MYSQL_PASSWORD + "&characterEncoding=utf-8");
com.jolbox.bonecp.BoneCPConfig config = new com.jolbox.bonecp.BoneCPConfig(); config.setUsername(dbUser); config.setPassword(dbPassword); Properties dbProps = getPropertiesForDriver(storeMgr); config.setDriverProperties(dbProps);
@Override public DataSource getDataSource(JsonObject config) throws SQLException { BoneCPConfig boneCPConfig = new BoneCPConfig(); mergeConfig(boneCPConfig, config); // we now need to change the default class loader mostly for the cases where // we do not use fat jars. In that case other connection pools will fail // loading the drivers boneCPConfig.setClassLoader(getClassLoader()); return new BoneCPDataSource(boneCPConfig); }
/** * Sets username to use for connections. Just delegates to setUsername for clients hardcoded * with "setUser" instead. * * @param username to set */ public void setUser(String username) { setUsername(username); }
public JDBCManager(String driver, String connectionUri, int nConnectionsPool, String userName, String password) throws SQLException, ClassNotFoundException { Class.forName(driver); BoneCPConfig config = new BoneCPConfig(); config.setJdbcUrl(connectionUri); config.setMinConnectionsPerPartition(nConnectionsPool); config.setMaxConnectionsPerPartition(nConnectionsPool); config.setUsername(userName); config.setPassword(password); config.setPartitionCount(1); config.setDefaultAutoCommit(false); connectionPool = new BoneCP(config); // setup the connection pool }
final Map<String, String> providerAttributes) BoneCPConfig config = new BoneCPConfig(); config.setJdbcUrl(connectionUrl); if (username != null) config.setUsername(username); config.setPassword(password); config.setProperties(properties);
object ConnectionPool { Class.forName("[ENTER DRIVER]") private val connstring = [ENTER YOUR STRING] private var cp : BoneCP = _ createConnectionPool() //upon init create the cp /** * Create a new connection pool */ def createConnectionPool() = { if(cp == null) { try { val config = new BoneCPConfig() config.setJdbcUrl(connstring) config.setMaxConnectionsPerPartition(3) config.setMinConnectionsPerPartition(1) config.setPartitionCount(1) cp = new BoneCP(config) } catch { case e: SQLException => e.printStackTrace() } } } def getConnection () = { cp.getConnection }
Properties props = new Properties(); props.setProperty("characterEncoding", "UTF-8"); props.setProperty("useUnicode", "true"); BoneCPConfig config = new BoneCPConfig(props); config.setJdbcUrl("jdbc:mysql://" + MYSQL_HOST_NAME + "/" + MYSQL_BASE_NAME);
final BoneCPConfig config = new BoneCPConfig(); config.setJdbcUrl(url); config.setUsername(user); config.setPassword(password); config.setMinConnectionsPerPartition(10); config.setMaxConnectionsPerPartition(20); config.setPartitionCount(1); connectionPool = new BoneCP(config);
@Override public DataSource create(Configuration hdpConfig) throws SQLException { LOG.debug("Creating BoneCP connection pool for the MetaStore"); String driverUrl = DataSourceProvider.getMetastoreJdbcDriverUrl(hdpConfig); String user = DataSourceProvider.getMetastoreJdbcUser(hdpConfig); String passwd = DataSourceProvider.getMetastoreJdbcPasswd(hdpConfig); int maxPoolSize = MetastoreConf.getIntVar(hdpConfig, MetastoreConf.ConfVars.CONNECTION_POOLING_MAX_CONNECTIONS); Properties properties = DataSourceProvider.getPrefixedProperties(hdpConfig, BONECP); long connectionTimeout = hdpConfig.getLong(CONNECTION_TIMEOUT_PROPERTY, 30000L); String partitionCount = properties.getProperty(PARTITION_COUNT_PROPERTY, "1"); BoneCPConfig config = null; try { config = new BoneCPConfig(properties); } catch (Exception e) { throw new SQLException("Cannot create BoneCP configuration: ", e); } config.setJdbcUrl(driverUrl); //if we are waiting for connection for a long time, something is really wrong //better raise an error than hang forever //see DefaultConnectionStrategy.getConnectionInternal() config.setConnectionTimeoutInMs(connectionTimeout); config.setMaxConnectionsPerPartition(maxPoolSize); config.setPartitionCount(Integer.parseInt(partitionCount)); config.setUser(user); config.setPassword(passwd); return new BoneCPDataSource(config); }
final Connection connection = connectionPool.getConnection(); ScheduledExecutorService exec = Executors.newSingleThreadScheduledExecutor(); BoneCPConfig config = new BoneCPConfig(); config.setJdbcUrl("jdbc:mysql://192.0.0.1:3306/database"); // jdbc url specific to your database, eg jdbc:mysql://127.0.0.1/yourdb config.setUsername("root"); config.setPassword(""); connectionPool = new BoneCP(config); return connectionPool;