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:mx.com.pixup.portal.dao.FormaPagoDaoJdbc.java
public FormaPagoDaoJdbc() { BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName("com.mysql.jdbc.Driver"); dataSource.setUsername("root"); dataSource.setPassword("admin"); //dataSource.setPassword("mysqlroot"); dataSource.setUrl("jdbc:mysql://localhost:3306/pixup"); this.dataSource = dataSource; }
From source file:com.stitchgalaxy.domain.spring.configuration.JpaConfig.java
@Bean public DataSource dataSource() { org.apache.commons.dbcp.BasicDataSource ds = new org.apache.commons.dbcp.BasicDataSource(); ds.setUrl(jdbcUrl);//from ww w.j av a2s.c om ds.setDriverClassName(driverClassName); ds.setUsername(username); ds.setPassword(password); ds.setInitialSize(4); ds.setDefaultAutoCommit(false); return ds; //EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder(); //return builder.setType(EmbeddedDatabaseType.HSQL).build(); }
From source file:com.thinkbiganalytics.jira.JiraSpringTestConfig.java
@Bean public DataSource dataSource() { BasicDataSource dataSource = new BasicDataSource(); dataSource.setUrl("jdbc:mysql://localhost:3306/pipeline_db"); dataSource.setUsername("root"); dataSource.setDriverClassName("org.mariadb.jdbc.Driver"); //dataSource.setPassword("password"); return dataSource; }
From source file:com.dangdang.ddframe.job.cloud.executor.TaskExecutor.java
@Override public void registered(final ExecutorDriver executorDriver, final Protos.ExecutorInfo executorInfo, final Protos.FrameworkInfo frameworkInfo, final Protos.SlaveInfo slaveInfo) { if (!executorInfo.getData().isEmpty()) { Map<String, String> data = SerializationUtils.deserialize(executorInfo.getData().toByteArray()); BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName(data.get("event_trace_rdb_driver")); dataSource.setUrl(data.get("event_trace_rdb_url")); dataSource.setPassword(data.get("event_trace_rdb_password")); dataSource.setUsername(data.get("event_trace_rdb_username")); jobEventBus = new JobEventBus(new JobEventRdbConfiguration(dataSource)); }// ww w .j av a 2s . c om }
From source file:net.kamhon.ieagle.dao.DynamicDataSource.java
private void initBasicDataSource() { BasicDataSource basicDataSource = new org.apache.commons.dbcp.BasicDataSource(); basicDataSource.setDriverClassName(driverClassName); basicDataSource.setUrl(url);/*from w ww . j a v a2s . c om*/ basicDataSource.setUsername(username); basicDataSource.setPassword(password); dataSource = basicDataSource; log.debug("DataSource - " + url); }
From source file:com.google.gerrit.server.schema.DataSourceProvider.java
private DataSource open(final SitePaths site, final Config cfg, final Context context, final DataSourceType dst) { ConfigSection dbs = new ConfigSection(cfg, "database"); String driver = dbs.optional("driver"); if (Strings.isNullOrEmpty(driver)) { driver = dst.getDriver();/*from w w w . ja v a 2 s .c o m*/ } String url = dbs.optional("url"); if (Strings.isNullOrEmpty(url)) { url = dst.getUrl(); } String username = dbs.optional("username"); String password = dbs.optional("password"); boolean usePool; if (context == Context.SINGLE_USER) { usePool = false; } else { usePool = cfg.getBoolean("database", "connectionpool", dst.usePool()); } if (usePool) { final BasicDataSource ds = new BasicDataSource(); ds.setDriverClassName(driver); ds.setUrl(url); if (username != null && !username.isEmpty()) { ds.setUsername(username); } if (password != null && !password.isEmpty()) { ds.setPassword(password); } ds.setMaxActive(cfg.getInt("database", "poollimit", 8)); ds.setMinIdle(cfg.getInt("database", "poolminidle", 4)); ds.setMaxIdle(cfg.getInt("database", "poolmaxidle", 4)); ds.setMaxWait(ConfigUtil.getTimeUnit(cfg, "database", null, "poolmaxwait", MILLISECONDS.convert(30, SECONDS), MILLISECONDS)); ds.setInitialSize(ds.getMinIdle()); return ds; } else { // Don't use the connection pool. // try { final Properties p = new Properties(); p.setProperty("driver", driver); p.setProperty("url", url); if (username != null) { p.setProperty("user", username); } if (password != null) { p.setProperty("password", password); } return new SimpleDataSource(p); } catch (SQLException se) { throw new ProvisionException("Database unavailable", se); } } }
From source file:architecture.ee.jdbc.datasource.DefaultDataSourceFactory.java
public DataSource getDataSource() { String profileTag = "database." + profileName; ApplicationProperties config = repository.getSetupApplicationProperties(); Collection<String> dataSourceProviders = config.getChildrenNames(profileTag); log.debug(CommonLogLocalizer.format("003040", profileName)); if (dataSourceProviders.size() == 0) throw new RuntimeError(CommonLogLocalizer.format("003041", profileName)); for (String dataSourceProvider : dataSourceProviders) { String providerTag = profileTag + "." + dataSourceProvider; if ("jndiDataSourceProvider".equals(dataSourceProvider)) { String jndiNameTag = providerTag + ".jndiName"; String jndiName = config.get(jndiNameTag + ".jndiName"); Assert.hasText(jndiName, CommonLogLocalizer.getMessage("003042")); JndiDataSourceLookup lookup = new JndiDataSourceLookup(); return lookup.getDataSource(jndiName); } else if ("pooledDataSourceProvider".equals(dataSourceProvider)) { String driverClassName = config.get(providerTag + ".driverClassName"); String url = config.get(providerTag + ".url"); String username = config.get(providerTag + ".username"); String password = config.get(providerTag + ".password"); log.debug(CommonLogLocalizer.format("003043", driverClassName, url)); org.apache.commons.dbcp.BasicDataSource dbcp = new org.apache.commons.dbcp.BasicDataSource(); dbcp.setDriverClassName(driverClassName); dbcp.setUrl(url);/*from w ww . j a v a2s .c om*/ dbcp.setUsername(username); dbcp.setPassword(password); String propertiesTag = providerTag + ".connectionProperties"; for (String name : config.getChildrenNames(propertiesTag)) { String value = config.get(propertiesTag + "." + name); log.debug(CommonLogLocalizer.format("003044", name, value)); dbcp.addConnectionProperty(name, value); } return dbcp; } } return null; }
From source file:au.com.jwatmuff.eventmanager.model.misc.SessionLockerTest.java
@Override protected void setUp() throws Exception { System.out.println("setup"); BasicDataSource ds = new BasicDataSource(); ds.setDriverClassName("org.sqlite.JDBC"); ds.setUrl("jdbc:sqlite::memory:"); this.dataSource = ds; }
From source file:de.iteratec.iteraplan.businesslogic.service.DataSourceServiceImpl.java
/** {@inheritDoc} */ public void initializeDBwithKey(String key) { DataSource dataSource = validateKey(key); if (dataSource == null) { // The key points to the MASTER data source. Nothing todo. return;/*from w ww . java2 s. co m*/ } // Validation succeeded. // Add the data source only if it is not contained already. if (!routingDataSource.isKeyContained(key)) { // Create a basic data source. BasicDataSource ds = new CachableBasicDataSource(); ds.setDriverClassName(dataSource.getDriver()); ds.setUrl(dataSource.getUrl()); ds.setUsername(dataSource.getUser()); ds.setPassword(dataSource.getPassword()); ds.setDefaultAutoCommit(false); String validationQuery = IteraplanProperties.getProperties() .getProperty(IteraplanProperties.DATABASE_VALIDATIONQUERY); ds.setValidationQuery(validationQuery); ds.setTestOnBorrow(true); // basicDataSource.setMaxActive(5); // basicDataSource.setMinIdle(1); routingDataSource.addCachableBasicDataSource(key, ds); } }
From source file:com.dangdang.ddframe.job.cloud.scheduler.boot.env.BootstrapEnvironment.java
/** * ???./*from www .j a v a 2 s.c o m*/ * * @return ?? */ public Optional<JobEventRdbConfiguration> getJobEventRdbConfiguration() { String driver = getValue(EnvironmentArgument.EVENT_TRACE_RDB_DRIVER); String url = getValue(EnvironmentArgument.EVENT_TRACE_RDB_URL); String username = getValue(EnvironmentArgument.EVENT_TRACE_RDB_USERNAME); String password = getValue(EnvironmentArgument.EVENT_TRACE_RDB_PASSWORD); if (!Strings.isNullOrEmpty(driver) && !Strings.isNullOrEmpty(url) && !Strings.isNullOrEmpty(username)) { BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName(driver); dataSource.setUrl(url); dataSource.setUsername(username); dataSource.setPassword(password); return Optional.of(new JobEventRdbConfiguration(dataSource)); } return Optional.absent(); }