List of usage examples for org.apache.commons.dbcp PoolableConnectionFactory hashCode
@HotSpotIntrinsicCandidate public native int hashCode();
From source file:jongo.jdbc.JDBCConnectionFactory.java
/** * Instantiates a new JDBCConnectionFactory if required and creates a connections pool for every database. * @return the instance of the singleton. *//*from w w w . j a va2 s . c o m*/ private static JDBCConnectionFactory instanceOf() { if (instance == null) { instance = new JDBCConnectionFactory(); for (DatabaseConfiguration db : configuration.getDatabases()) { l.debug("Registering Connection Pool for {}", db.getDatabase()); GenericObjectPool pool = new GenericObjectPool(null, db.getMaxConnections()); ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(db.toJdbcURL(), db.getUsername(), db.getPassword()); PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory( connectionFactory, pool, null, null, db.isReadOnly(), true); poolableConnectionFactory.hashCode(); instance.connectionPool.put(db.getDatabase(), pool); } } return instance; }
From source file:backtype.storm.scheduler.adaptive.DataManager.java
private DataManager() { logger = Logger.getLogger(DataManager.class); logger.info("Starting DataManager (working directory: " + System.getProperty("user.dir") + ")"); try {//from ww w.ja v a 2 s. co m // load configuration from file logger.debug("Loading configuration from file"); Properties properties = new Properties(); properties.load(new FileInputStream("db.ini")); logger.debug("Configuration loaded"); // load JDBC driver logger.debug("Loading JDBC driver"); String jdbc_driver = properties.getProperty("jdbc.driver").trim(); Class.forName(jdbc_driver); logger.debug("Driver loaded"); // set up data source logger.debug("Setting up pooling data source"); String connection_uri = properties.getProperty("data.connection.uri"); String validation_query = properties.getProperty("validation.query"); ObjectPool connectionPool = new GenericObjectPool(null); ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(connection_uri, null); PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory(connectionFactory, connectionPool, null, validation_query, false, true); poolableConnectionFactory.hashCode(); dataSource = new PoolingDataSource(connectionPool); logger.debug("Data source set up"); nodeName = properties.getProperty("node-name"); if (properties.getProperty("capacity") != null) { capacity = Integer.parseInt(properties.getProperty("capacity")); if (capacity < 1 || capacity > 100) throw new RuntimeException("Wrong capacity: " + capacity + ", expected in the range [1, 100]"); } logger.info("DataManager started"); } catch (Exception e) { logger.error("Error starting DataManager", e); } }
From source file:org.jongo.jdbc.JDBCConnectionFactory.java
/** * Instantiates a new JDBCConnectionFactory if required and creates a connections pool for every database. * @return the instance of the singleton. */// w ww .j a v a 2s . c o m private static JDBCConnectionFactory instanceOf() { if (instance == null) { instance = new JDBCConnectionFactory(); for (DatabaseConfiguration db : configuration.getDatabases()) { l.debug("Registering Connection Pool for " + db.getDatabase()); GenericObjectPool pool = new GenericObjectPool(null, db.getMaxConnections()); ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(db.toJdbcURL(), db.getUsername(), db.getPassword()); PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory( connectionFactory, pool, null, null, db.isReadOnly(), true); poolableConnectionFactory.hashCode(); instance.connectionPool.put(db.getDatabase(), pool); } } return instance; }
From source file:storm.scheduler.DataManager.java
private DataManager() { logger = Logger.getLogger(DataManager.class); logger.info("Starting DataManager (working directory: " + System.getProperty("user.dir") + ")"); try {/*from w ww . jav a 2s.c om*/ // load configuration from file logger.debug("Loading configuration from file"); Properties properties = new Properties(); properties.load(new FileInputStream("/home/miller/research/storm/apache-storm-0.9.3/db.ini")); logger.debug("Configuration loaded"); // load JDBC driver logger.debug("Loading JDBC driver"); String jdbc_driver = properties.getProperty("jdbc.driver").trim(); Class.forName(jdbc_driver); logger.debug("Driver loaded"); // set up data source logger.debug("Setting up pooling data source"); String connection_uri = properties.getProperty("data.connection.uri"); String validation_query = properties.getProperty("validation.query"); ObjectPool connectionPool = new GenericObjectPool(null); ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(connection_uri, properties); PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory(connectionFactory, connectionPool, null, validation_query, false, true); poolableConnectionFactory.hashCode(); dataSource = new PoolingDataSource(connectionPool); logger.debug("Data source set up"); nodeName = properties.getProperty("node-name"); if (properties.getProperty("capacity") != null) { capacity = Integer.parseInt(properties.getProperty("capacity")); if (capacity < 1 || capacity > 100) throw new RuntimeException("Wrong capacity: " + capacity + ", expected in the range [1, 100]"); } logger.info("DataManager started"); } catch (Exception e) { logger.error("Error starting DataManager", e); } }