List of usage examples for org.apache.commons.dbcp BasicDataSource setDriverClassName
public synchronized void setDriverClassName(String driverClassName)
Sets the jdbc driver class name.
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);/*from w w w .ja v a2 s . com*/ dataSource.setUsername(dbuser); 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:io.apiman.manager.test.server.ManagerApiTestServer.java
/** * Creates an in-memory datasource.//from w ww . j ava2 s . co m * @throws SQLException */ private static BasicDataSource createInMemoryDatasource() throws SQLException { System.setProperty("hibernate.dialect", "org.hibernate.dialect.H2Dialect"); //$NON-NLS-1$ //$NON-NLS-2$ BasicDataSource ds = new BasicDataSource(); ds.setDriverClassName(Driver.class.getName()); ds.setUsername("sa"); //$NON-NLS-1$ ds.setPassword(""); //$NON-NLS-1$ ds.setUrl("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1"); //$NON-NLS-1$ Connection connection = ds.getConnection(); connection.close(); System.out.println("DataSource created and bound to JNDI."); //$NON-NLS-1$ return ds; }
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 w w . j a v a 2s . 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);/*from w w w .j a v a 2 s . c om*/ source.setMaxIdle(4); return source; }
From source file:gsn.storage.DataSources.java
public static BasicDataSource getDataSource(DBConnectionInfo dci) { BasicDataSource ds = null; try {/*w w w.j a va2 s . c om*/ ds = (BasicDataSource) GSNContext.getMainContext().lookup(Integer.toString(dci.hashCode())); if (ds == null) { ds = new BasicDataSource(); ds.setDriverClassName(dci.getDriverClass()); ds.setUsername(dci.getUserName()); ds.setPassword(dci.getPassword()); ds.setUrl(dci.getUrl()); //ds.setDefaultTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED); //ds.setAccessToUnderlyingConnectionAllowed(true); GSNContext.getMainContext().bind(Integer.toString(dci.hashCode()), ds); logger.warn("Created a DataSource to: " + ds.getUrl()); } } catch (NamingException e) { logger.error(e.getMessage(), e); } return ds; }
From source file:io.apiman.gateway.engine.jdbc.JdbcMetricsTest.java
/** * Creates an in-memory datasource.//from w w w . ja va2 s. co m * @throws SQLException */ private static BasicDataSource createInMemoryDatasource() throws Exception { BasicDataSource ds = new BasicDataSource(); ds.setDriverClassName(Driver.class.getName()); ds.setUsername("sa"); ds.setPassword(""); ds.setUrl("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1"); Connection connection = ds.getConnection(); connection.setAutoCommit(true); initDB(connection); connection.close(); return ds; }
From source file:io.apiman.gateway.engine.policies.BasicAuthJDBCTest.java
/** * Creates an in-memory datasource./*from w w w. j a v a 2 s .c om*/ * @throws SQLException */ private static BasicDataSource createInMemoryDatasource() throws SQLException { BasicDataSource ds = new BasicDataSource(); ds.setDriverClassName(Driver.class.getName()); ds.setUsername("sa"); //$NON-NLS-1$ ds.setPassword(""); //$NON-NLS-1$ ds.setUrl("jdbc:h2:mem:BasicAuthJDBCTest;DB_CLOSE_DELAY=-1"); //$NON-NLS-1$ Connection connection = ds.getConnection(); connection.prepareStatement( "CREATE TABLE users ( username varchar(255) NOT NULL, password varchar(255) NOT NULL, PRIMARY KEY (username))") .executeUpdate(); connection.prepareStatement( "INSERT INTO users (username, password) VALUES ('bwayne', 'ae2efd698aefdf366736a4eda1bc5241f9fbfec7')") .executeUpdate(); connection.prepareStatement( "INSERT INTO users (username, password) VALUES ('ckent', 'ea59f7ca52a2087c99374caba0ff29be1b2dcdbf')") .executeUpdate(); connection.prepareStatement( "INSERT INTO users (username, password) VALUES ('ballen', 'ea59f7ca52a2087c99374caba0ff29be1b2dcdbf')") .executeUpdate(); connection .prepareStatement( "CREATE TABLE roles (rolename varchar(255) NOT NULL, username varchar(255) NOT NULL)") .executeUpdate(); connection.prepareStatement("INSERT INTO roles (rolename, username) VALUES ('user', 'bwayne')") .executeUpdate(); connection.prepareStatement("INSERT INTO roles (rolename, username) VALUES ('admin', 'bwayne')") .executeUpdate(); connection.prepareStatement("INSERT INTO roles (rolename, username) VALUES ('ckent', 'user')") .executeUpdate(); connection.prepareStatement("INSERT INTO roles (rolename, username) VALUES ('ballen', 'user')") .executeUpdate(); connection.close(); return ds; }
From source file:com.dangdang.ddframe.job.event.rdb.JobEventRdbSearchTest.java
@BeforeClass public static void setUpClass() throws SQLException { BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName(org.h2.Driver.class.getName()); dataSource.setUrl("jdbc:h2:mem:"); dataSource.setUsername("sa"); dataSource.setPassword(""); storage = new JobEventRdbStorage(dataSource); repository = new JobEventRdbSearch(dataSource); initStorage();//from ww w . ja v a2 s. c o m }
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);//from w w w . j a va2s . c o m datasource.setMaxActive(50); datasource.setMinIdle(4); datasource.setMaxIdle(16); long evictIdleTimeMs = 1000 * 60; datasource.setMinEvictableIdleTimeMillis(evictIdleTimeMs); datasource.setTimeBetweenEvictionRunsMillis(evictIdleTimeMs / 2); return datasource; }
From source file:demo.learn.shiro.util.SqlUtil.java
/** * Gets the basic {@link DataSource}. Hard-coded * in this util. There is a script, mysql.sql, to * create the MySQL database.//from ww w . j a v a 2 s . c om * @return {@link DataSource}. */ public static DataSource getBasicDataSource() { if (null == _basicDataSource) { BasicDataSource ds = new BasicDataSource(); ds.setUsername("secure"); ds.setPassword("secure#123}{"); ds.setDriverClassName("com.mysql.jdbc.Driver"); ds.setUrl("jdbc:mysql://mysql:3306/secure?profileSQL=false"); ds.setMaxActive(10); _basicDataSource = ds; } return _basicDataSource; }