List of usage examples for org.apache.commons.dbcp BasicDataSource setUrl
public synchronized void setUrl(String url)
Sets the #url .
Note: this method currently has no effect once the pool has been initialized.
From source file:edu.ncsa.uiuc.rdfrepo.testing.USeekMSailFac.java
public static IndexingSail getIndexingSail(String dburl, String dbuser, String password, String capturepredicate, RepositorySail sail) throws SailException { //set tup the postgis datasource for indexer BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName("org.postgresql.Driver"); dataSource.setUrl(dburl); dataSource.setUsername(dbuser);//w w w. j ava 2 s . c om dataSource.setPassword(password); PostgisIndexerSettings indexerSettings = new PostgisIndexerSettings(); indexerSettings.setDataSource(dataSource); String patternString = "?observation <http://purl.oclc.org/NET/ssnx/ssn#observationResultTime> ?time." + "?time <http://www.w3.org/2006/time#inXSDDateTime> ?timevalue. " + "?loc <http://www.opengis.net/rdf#hasWKT> ?coord. " + "?sensor <http://www.loa-cnr.it/ontologies/DUL.owl#hasLocation> ?loc." + "?observation <http://purl.oclc.org/NET/ssnx/ssn#observedBy> ?sensor. "; // String patternString = // "?geometry <http://www.opengis.net/rdf#hasWKT> ?wkt."; sail.initialize(); indexerSettings.setMatchSatatments(createPatternFromString(patternString, sail)); indexerSettings.setDataSource(dataSource); //a matcher decides which object should be indexed by its associated predicate, we can use "http://www.opengis.net/rdf#hasWKT" PostgisIndexMatcher matcher = new PostgisIndexMatcher(); matcher.setPredicate(capturepredicate); //create a IndexingSail from the basic sail and the indexer indexerSettings.setMatchers(Arrays.asList(new PostgisIndexMatcher[] { matcher })); return null; // PartitionDef p = new P // IndexingSail indexingSail = new IndexingSail(sail, indexerSettings); // // indexingSail.initialize(); // return indexingSail; }
From source file:com.oncecorp.visa3d.bridge.utility.JdbcUtils.java
/** * This method create and returns the client data source object. In this class, * we use "Jakarta-commons-release" to create the data source object. * @param driverClass The JDBC driver class name. * @param jdbcURL The database URL./*from w w w . ja v a 2s . c o m*/ * @param jdbcUID The database user id. * @param jdbcPW The database password. * @param maxConns maximum connections * @param timeOut connection timeout * @return The data Source object. */ public static DataSource createPoolingDataSoruce(String driverClass, String jdbcURL, String jdbcUID, String jdbcPW, int maxConns, int timeOut) { try { Class.forName(driverClass); BasicDataSource bds = new BasicDataSource(); bds.setDriverClassName(driverClass); bds.setMaxActive(maxConns); bds.setMaxWait(timeOut); bds.setUrl(jdbcURL); bds.setUsername(jdbcUID); bds.setPassword(jdbcPW); System.out.println("Use dbcp pool with datasource = " + bds); return bds; } catch (Exception e) { System.out.println("Data Source creating failed. -- " + driverClass + ", " + jdbcURL + ", " + jdbcUID + ", " + jdbcPW + ", ==" + e.getMessage()); return null; } }
From source file:com.plexobject.testplayer.dao.hibernate.GenericDaoHibernate.java
protected static DataSource getDataSource() { BasicDataSource source = new BasicDataSource(); source.setDriverClassName("com.mysql.jdbc.Driver"); source.setUrl("jdbc:mysql://localhost/testplayer"); source.setUsername("root"); source.setPassword("root"); source.setMaxActive(15);/* w ww . j a v a2s . c o m*/ source.setMaxIdle(4); return source; }
From source file:com.plexobject.testplayer.dao.hibernate.GenericDaoHibernate.java
protected static DataSource _getDataSource() { BasicDataSource source = new BasicDataSource(); source.setDriverClassName("org.hsqldb.jdbcDriver"); source.setUrl("jdbc:hsqldb:file:testplayer.db"); //source.setUrl("jdbc:hsqldb:hsql://localhost/testplayer"); source.setUsername("sa"); source.setPassword(""); source.setMaxActive(15);//w ww.jav a 2 s . com source.setMaxIdle(4); return source; }
From source file:io.apicurio.hub.core.editing.EditingSessionManagerTest.java
/** * Creates an in-memory datasource./*from w w w .jav a2s . co m*/ * @throws SQLException */ private static BasicDataSource createInMemoryDatasource() { BasicDataSource ds = new BasicDataSource(); ds.setDriverClassName(Driver.class.getName()); ds.setUsername("sa"); ds.setPassword(""); ds.setUrl("jdbc:h2:mem:test" + (counter++) + ";DB_CLOSE_DELAY=-1"); return ds; }
From source file:cz.muni.fi.pv168.dressroommanager.ClosetManagerImplTest.java
private static DataSource prepareDataSource() throws SQLException { BasicDataSource ds = new BasicDataSource(); //we will use in memory database ds.setUrl("jdbc:derby:memory:dressroom-test;create=true"); return ds;/*ww w.jav a2s . c o m*/ }
From source file:com.util.conectividad.ConectorDB.java
public static Connection obtenerConexionBasica() { Connection conexion = null;/*from w w w.j a v a 2s . c om*/ BasicDataSource basicDataSource = null; try { basicDataSource = new BasicDataSource(); basicDataSource.setDriverClassName("oracle.jdbc.driver.OracleDriver"); // basicDataSource.setUrl("jdbc:oracle:thin:@192.168.21.241:1521/pdb1");// local basicDataSource.setUrl("jdbc:oracle:thin:@172.28.80.32:1525/INTERAT1");// local // basicDataSource.setUsername("interacttdp");// local basicDataSource.setUsername("USR_INTERACT_APP"); // basicDataSource.setPassword("interacttdp99");// local basicDataSource.setPassword("RT87TY"); basicDataSource.setInitialSize(5); basicDataSource.setMaxActive(2); conexion = basicDataSource.getConnection(); return conexion; } catch (Exception e) { return conexion; } finally { basicDataSource = null; conexion = null; } }
From source file:com.devwebsphere.jdbc.loader.JDBCTxCallback.java
public synchronized static DataSource setupDataSource(String connectURI, String user, String password) { String key = connectURI + ":" + user + ":" + password; DataSource rc = dataSourceList.get(key); if (rc == null) { ///* w ww . j a v a 2s . c o m*/ // First, we'll need a ObjectPool that serves as the // actual pool of connections. // // We'll use a GenericObjectPool instance, although // any ObjectPool implementation will suffice. // BasicDataSource bds = new BasicDataSource(); bds.setInitialSize(5); bds.setUrl(connectURI); bds.setUsername(user); bds.setPassword(password); bds.setPoolPreparedStatements(true); rc = bds; dataSourceList.put(key, bds); } return rc; }
From source file:net.hydromatic.optiq.impl.jdbc.JdbcSchema.java
/** Creates a JDBC data source with the given specification. */ public static DataSource dataSource(String url, String driverClassName, String username, String password) { if (url.startsWith("jdbc:hsqldb:")) { // Prevent hsqldb from screwing up java.util.logging. System.setProperty("hsqldb.reconfig_logging", "false"); }// ww w . java2s .co m BasicDataSource dataSource = new BasicDataSource(); dataSource.setUrl(url); dataSource.setUsername(username); dataSource.setPassword(password); dataSource.setDriverClassName(driverClassName); return dataSource; }
From source file:com.google.gerrit.server.schema.H2AccountPatchReviewStore.java
private static DataSource createDataSource(String url) { BasicDataSource datasource = new BasicDataSource(); datasource.setDriverClassName("org.h2.Driver"); datasource.setUrl(url); datasource.setMaxActive(50);// ww w. j a v a 2 s . c o m datasource.setMinIdle(4); datasource.setMaxIdle(16); long evictIdleTimeMs = 1000 * 60; datasource.setMinEvictableIdleTimeMillis(evictIdleTimeMs); datasource.setTimeBetweenEvictionRunsMillis(evictIdleTimeMs / 2); return datasource; }