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:org.chaston.oakfunds.jdbc.AppEngineDataStoreModule.java
@Provides @Singleton/* www. j a va2 s.c o m*/ DataSource provideDataSource() throws SQLException { BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName("com.mysql.jdbc.GoogleDriver"); dataSource.setUrl( "jdbc:google:mysql://mchaston-oakfunds:oakfunds2/" + SystemColumnDefs.SCHEMA + "?user=root"); return dataSource; }
From source file:org.compass.core.lucene.engine.store.jdbc.DbcpDataSourceProvider.java
protected DataSource doCreateDataSource(String url, CompassSettings settings) throws CompassException { BasicDataSource dataSource = new BasicDataSource(); if (!externalAutoCommit) { dataSource.setDefaultAutoCommit(autoCommit); }//w w w . j a v a 2 s .co m dataSource.setDriverClassName(driverClass); dataSource.setUrl(url); dataSource.setUsername(username); dataSource.setPassword(password); if (settings.getSetting( LuceneEnvironment.JdbcStore.DataSourceProvider.Dbcp.DEFAULT_TRANSACTION_ISOLATION) != null) { dataSource.setDefaultTransactionIsolation(settings.getSettingAsInt( LuceneEnvironment.JdbcStore.DataSourceProvider.Dbcp.DEFAULT_TRANSACTION_ISOLATION, 0)); } if (settings.getSetting(LuceneEnvironment.JdbcStore.DataSourceProvider.Dbcp.INITIAL_SIZE) != null) { dataSource.setInitialSize( settings.getSettingAsInt(LuceneEnvironment.JdbcStore.DataSourceProvider.Dbcp.INITIAL_SIZE, 0)); } if (settings.getSetting(LuceneEnvironment.JdbcStore.DataSourceProvider.Dbcp.MAX_ACTIVE) != null) { dataSource.setMaxActive( settings.getSettingAsInt(LuceneEnvironment.JdbcStore.DataSourceProvider.Dbcp.MAX_ACTIVE, 0)); } if (settings.getSetting(LuceneEnvironment.JdbcStore.DataSourceProvider.Dbcp.MAX_IDLE) != null) { dataSource.setMaxIdle( settings.getSettingAsInt(LuceneEnvironment.JdbcStore.DataSourceProvider.Dbcp.MAX_IDLE, 0)); } if (settings.getSetting(LuceneEnvironment.JdbcStore.DataSourceProvider.Dbcp.MIN_IDLE) != null) { dataSource.setMinIdle( settings.getSettingAsInt(LuceneEnvironment.JdbcStore.DataSourceProvider.Dbcp.MIN_IDLE, 0)); } if (settings.getSetting(LuceneEnvironment.JdbcStore.DataSourceProvider.Dbcp.MAX_WAIT) != null) { dataSource.setMaxWait( settings.getSettingAsLong(LuceneEnvironment.JdbcStore.DataSourceProvider.Dbcp.MAX_WAIT, 0)); } if (settings.getSetting( LuceneEnvironment.JdbcStore.DataSourceProvider.Dbcp.MAX_OPEN_PREPARED_STATEMENTS) != null) { dataSource.setMaxOpenPreparedStatements(settings.getSettingAsInt( LuceneEnvironment.JdbcStore.DataSourceProvider.Dbcp.MAX_OPEN_PREPARED_STATEMENTS, 0)); } if (settings .getSetting(LuceneEnvironment.JdbcStore.DataSourceProvider.Dbcp.POOL_PREPARED_STATEMENTS) != null) { dataSource.setPoolPreparedStatements(settings.getSettingAsBoolean( LuceneEnvironment.JdbcStore.DataSourceProvider.Dbcp.POOL_PREPARED_STATEMENTS, false)); } return dataSource; }
From source file:org.danann.cernunnos.sql.BasicDataSourceTemplate.java
public final void perform(TaskRequest req, TaskResponse res) { //Get the JDBC properties final String driverClassName = (String) this.driverPhrase.evaluate(req, res); final String url = (String) this.urlPhrase.evaluate(req, res); final String username = (String) this.usernamePhrase.evaluate(req, res); final String password = (String) this.passwordPhrase.evaluate(req, res); final String dataSourceInfo = "driverClassName='" + driverClassName + "', url='" + url + "', username='" + username + "'"; this.logger.debug("Creating DataSource for " + dataSourceInfo + "."); final BasicDataSource dataSource = new BasicDataSource(); try {/*w w w.j ava 2 s. c o m*/ //Configure the pooling DataSource dataSource.setUrl(url); dataSource.setDriverClassName(driverClassName); dataSource.setUsername(username); dataSource.setPassword(password); dataSource.setPoolPreparedStatements(true); dataSource.setMaxActive(-1); dataSource.setMaxIdle(32); //Provide the DataSource on the response environment final String dataSourceAttrName = (String) this.attributeNamePhrase.evaluate(req, res); res.setAttribute(dataSourceAttrName, dataSource); this.logger.debug("Attached DataSource '" + dataSource + "' for " + dataSourceInfo + " to response under attribute '" + dataSourceAttrName + "'."); //Execute subtasks this.performWithDataSource(req, res, dataSource); } finally { try { //Cleanup after the subtasks dataSource.close(); this.logger.debug("Closed DataSource '" + dataSource + "' for " + dataSourceInfo + "."); } catch (SQLException e) { throw new RuntimeException( "Failed to close BasicDataSource '" + dataSource + "' for " + dataSourceInfo + ".", e); } } }
From source file:org.datacleaner.test.TestHelper.java
public static DataSource createSampleDatabaseDataSource() { BasicDataSource _dataSource = new BasicDataSource(); _dataSource.setDriverClassName("org.hsqldb.jdbcDriver"); _dataSource.setUrl("jdbc:hsqldb:res:testwareorderdb;readonly=true"); _dataSource.setMaxActive(-1);//from w w w. j av a 2 s . com _dataSource.setDefaultAutoCommit(false); return _dataSource; }
From source file:org.devproof.portal.test.JettyStart.java
public static void main(final String[] args) throws Exception { if (args.length != 5) { System.out.println("JettyStart <DbUser/Pass/Schema> <httpport> <smtphost> <smtpuser> <smtppass>"); return;// w w w.ja v a 2 s .co m } Server server = new Server(); SocketConnector connector = new SocketConnector(); // Set some timeout options to make debugging easier. connector.setMaxIdleTime(1000 * 60 * 60); connector.setSoLingerTime(-1); connector.setPort(Integer.valueOf(args[1])); server.setConnectors(new Connector[] { connector }); WebAppContext bb = new WebAppContext(); bb.setServer(server); bb.setContextPath("/"); bb.setWar(System.getProperty("java.io.tmpdir")); bb.addEventListener(new PortalContextLoaderListener()); FilterHolder filter = new FilterHolder(); filter.setInitParameter("applicationClassName", PortalApplication.class.getName()); // servlet.setInitParameter("configuration", "deployment"); filter.setClassName(WicketFilter.class.getName()); filter.setName(WicketFilter.class.getName()); bb.addFilter(filter, "/*", 1); server.addHandler(bb); BasicDataSource datasource = new BasicDataSource(); datasource.setUrl("jdbc:mysql://localhost/" + args[0]); datasource.setUsername(args[0]); datasource.setPassword(args[0]); datasource.setDriverClassName(Driver.class.getName()); new Resource(CommonConstants.JNDI_DATASOURCE, datasource); Properties props = System.getProperties(); props.put("mail.smtp.host", args[2]); props.put("mail.smtp.auth", "true"); props.put("mail.transport.protocol", "smtp"); props.put("mail.smtp.port", "25"); props.put("mail.smtp.starttls.enable", "true"); props.put("mail.debug", "true"); Authenticator auth = new Authenticator() { @Override protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(args[3], args[4]); } }; Session mailSession = Session.getDefaultInstance(props, auth); new Resource(CommonConstants.JNDI_MAIL_SESSION, mailSession); new Resource(CommonConstants.JNDI_PROP_EMAIL_DISABLED, "true"); // START JMX SERVER MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer(); MBeanContainer mBeanContainer = new MBeanContainer(mBeanServer); server.getContainer().addEventListener(mBeanContainer); mBeanContainer.start(); try { System.out.println(">>> STARTING DEVPROOF PORTAL, PRESS ANY KEY TO STOP"); server.start(); while (System.in.available() == 0) { Thread.sleep(5000); } server.stop(); server.join(); } catch (Exception e) { e.printStackTrace(); System.exit(100); } }
From source file:org.docksidestage.dockside.JdbcBeansJavaConfig.java
@Bean(name = "dataSource") public DataSource createDataSource() { BasicDataSource ds = new BasicDataSource(); ds.setDriverClassName("org.h2.Driver"); ds.setUrl(maihamaDbUrl);// w ww. ja v a 2 s .c om ds.setUsername("sa"); ds.setPassword(""); ds.setMaxActive(20); return ds; }
From source file:org.docksidestage.oracle.JdbcBeansJavaConfig.java
@Bean(name = "dataSource") public DataSource createDataSource() { BasicDataSource ds = new BasicDataSource(); ds.setDriverClassName("oracle.jdbc.driver.OracleDriver"); ds.setUrl(JdbcDiconResolver.resolveUrl("jdbc:oracle:thin:@localhost:1521:XE")); ds.setUsername("maihamadb"); ds.setPassword("maihamadb"); ds.setMaxActive(20);/*from ww w . j a v a 2 s. com*/ return ds; }
From source file:org.docksidestage.oracle.JdbcBeansResolaJavaConfig.java
@Bean(name = "resolaDataSource") public DataSource createDataSource() { BasicDataSource ds = new BasicDataSource(); ds.setDriverClassName("oracle.jdbc.driver.OracleDriver"); ds.setUrl(JdbcDiconResolver.resolveUrl("jdbc:oracle:thin:@localhost:1521:XE")); ds.setUsername("resortlinedb"); ds.setPassword("resortlinedb"); ds.setMaxActive(20);// w ww . j a va 2s . c o m return ds; }
From source file:org.duracloud.mill.credentials.impl.CredentialsRepoConfig.java
@Bean(name = CREDENTIALS_REPO_DATA_SOURCE_BEAN, destroyMethod = "close") public BasicDataSource credentialsRepoDataSource() { BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName("com.mysql.jdbc.Driver"); dataSource.setUrl(MessageFormat.format("jdbc:mysql://{0}:{1}/{2}?autoReconnect=true", System.getProperty(ConfigConstants.MC_DB_HOST, "localhost"), System.getProperty(ConfigConstants.MC_DB_PORT, "3306"), System.getProperty(ConfigConstants.MC_DB_NAME, "mill"))); dataSource.setUsername(System.getProperty(ConfigConstants.MC_DB_USER, "mill")); dataSource.setPassword(System.getProperty(ConfigConstants.MC_DB_PASS, "password")); return dataSource; }
From source file:org.eclipse.data.sampledb.SampledbActivator.java
private DataSource getDataSource() { BasicDataSource ds = new BasicDataSource(); ds.setDriverClassName(DERBY_DRIVER_CLASS); ds.setUsername(SAMPLE_DB_SCHEMA);//from w w w .j a v a 2 s. c om ds.setPassword(EMPTY_VALUE); ds.setUrl(getDBUrl()); return ds; }