Example usage for org.apache.commons.dbcp BasicDataSource setDriverClassName

List of usage examples for org.apache.commons.dbcp BasicDataSource setDriverClassName

Introduction

In this page you can find the example usage for org.apache.commons.dbcp BasicDataSource setDriverClassName.

Prototype

public synchronized void setDriverClassName(String driverClassName) 

Source Link

Document

Sets the jdbc driver class name.

Note: this method currently has no effect once the pool has been initialized.

Usage

From source file:sistema.Conexion.java

private void inicializaDataSource() {

    BasicDataSource basicDataSource = new BasicDataSource();

    basicDataSource.setDriverClassName("org.gjt.mm.mysql.Driver");
    basicDataSource.setUsername(login);/*from ww w  .ja va2  s.c  o m*/
    basicDataSource.setPassword(pass);
    basicDataSource.setUrl(url);
    basicDataSource.setMaxActive(50);

    dataSource = basicDataSource;

}

From source file:skoa.helpers.ConfiguracionGraficas.java

private void inicializaDataSource() {
    BasicDataSource basicDataSource = new BasicDataSource();
    basicDataSource.setDriverClassName("com.mysql.jdbc.Driver");
    basicDataSource.setUsername(user);/*  w w w .j ava  2 s  .c  om*/
    basicDataSource.setPassword(pass);
    basicDataSource.setUrl(url);
    basicDataSource.setMaxActive(4);
    // Opcional. Sentencia SQL que sirve a BasicDataSource para comprobar que la conexion es correcta.
    basicDataSource.setValidationQuery("select 1");
    dataSource = basicDataSource;
}

From source file:test.gov.nih.nci.logging.api.persistence.TestSpringLocationSessionFactoryBean.java

private static BasicDataSource setDataSourceProperties() {
    BasicDataSource ds = new BasicDataSource();
    ds.setDriverClassName("com.mysql.jdbc.Driver");
    ds.setUrl("jdbc:mysql://localhost:3306/clm");
    ds.setUsername("root");
    ds.setPassword("admin");
    /*props.setProperty("hibernate.dialect","org.hibernate.dialect.MySQLDialect");
    props.setProperty("jdbc.batch_size","30");*/
    return ds;/*from   ww w. j a va  2  s  . c  om*/
}

From source file:tp.project.trafficviolationsystem.app.conf.ConnectionConfig.java

@Bean
public DataSource dataSource() {
    BasicDataSource ds = new org.apache.commons.dbcp.BasicDataSource();
    ds.setDriverClassName("org.apache.derby.jdbc.ClientDriver");
    ds.setUrl("jdbc:derby://localhost:1527/tvs");
    ds.setUsername("tvs_user");
    ds.setPassword("tvs_user");
    return ds;//from w w  w . java2s  .com
}

From source file:ttf.util.AppContext.java

private AppContext(Configuration c) {
    // data source
    BasicDataSource bds = new BasicDataSource();
    bds.setDriverClassName(c.getString("db.driverClassName"));
    bds.setUsername(c.getString("db.username"));
    bds.setPassword(c.getString("db.password"));
    bds.setUrl(c.getString("db.uri"));
    dataSource = bds;/*from   w  w  w.j  a  v  a2  s. co m*/

    // model handlers
    articleFactory = new BasicArticleFactory();
    topicFactory = new BasicTopicFactory();
    modelStore = new SQLStore(dataSource, articleFactory, topicFactory);

    // processing
    String key = c.getString("alchemy.key");
    AlchemyAPI alchemyAPI = AlchemyAPI.GetInstanceFromString(key);
    EntityDetector entityDetector = new EntityDetector(alchemyAPI);
    TfIdfDetector tfIdfDetector = new TfIdfDetector(new TfIdf());
    SimilarityComputer similarityComputer = new SimilarityComputer();

    contextFactory = new ContextFactory( //
            articleFactory, topicFactory, //
            modelStore, //
            alchemyAPI, entityDetector, tfIdfDetector, similarityComputer);
}

From source file:uk.ac.ebi.sail.server.data.DataManager.java

private static DataSource setupDataSource(BackendConfigurationManager defaultCfg) {
    BasicDataSource ds = new BasicDataSource();

    ds.setDriverClassName(defaultCfg.getDBDriverClass());
    ds.setUsername(defaultCfg.getDBUserName());
    ds.setPassword(defaultCfg.getDBPassword());
    ds.setUrl(defaultCfg.getConnectionURL());

    ds.setTimeBetweenEvictionRunsMillis(10000);

    return ds;//from  ww  w  . jav a2  s .c o  m
}

From source file:voldemort.performance.MysqlBench.java

public MysqlBench(String table, int numThreads, int numRequests, String connectionString, String username,
        String password, String requestFile, boolean doReads, boolean doWrites) {
    this.table = table;
    this.numThreads = numThreads;
    this.numRequests = numRequests;
    BasicDataSource ds = new BasicDataSource();
    ds.setDriverClassName("com.mysql.jdbc.Driver");
    ds.setUsername(username);/*from   w  w w.j  a  v a2  s.co m*/
    ds.setPassword(password);
    ds.setUrl(connectionString);
    this.requestFile = requestFile;
    this.dataSource = ds;
    this.doReads = doReads;
    this.doWrites = doWrites;
}

From source file:voldemort.performance.MysqlGrowth.java

public static void main(String[] args) throws Exception {
    if (args.length != 3) {
        System.err.println("USAGE: java MySQLGrowth total_size increment threads");
        System.exit(1);//  w w  w.j  a v  a2  s  .  c o  m
    }
    final int totalSize = Integer.parseInt(args[0]);
    final int increment = Integer.parseInt(args[1]);
    final int threads = Integer.parseInt(args[2]);

    BasicDataSource ds = new BasicDataSource();
    ds.setDriverClassName("com.mysql.jdbc.Driver");
    ds.setUsername("root");
    ds.setPassword("");
    ds.setUrl("jdbc:mysql://127.0.0.1:3306/test");
    final Connection conn = ds.getConnection();
    conn.createStatement().execute("truncate table test_table");

    final Random rand = new Random();
    int iterations = totalSize / increment;
    long[] readTimes = new long[iterations];
    long[] writeTimes = new long[iterations];
    ExecutorService service = Executors.newFixedThreadPool(threads);
    for (int i = 0; i < iterations; i++) {
        System.out.println("Starting iteration " + i);
        List<Future<Object>> results = new ArrayList<Future<Object>>(increment);
        long startTime = System.currentTimeMillis();
        final int fi = i;
        for (int j = 0; j < increment; j++) {
            final int fj = j;
            results.add(service.submit(new Callable<Object>() {

                public Object call() throws Exception {
                    upsert(conn, Integer.toString(fi * increment + fj), Integer.toString(fi * increment + fj));
                    return null;
                }
            }));
        }
        for (int j = 0; j < increment; j++)
            results.get(j).get();
        writeTimes[i] = System.currentTimeMillis() - startTime;
        System.out.println("write: " + (writeTimes[i] / (double) increment));
        results.clear();

        startTime = System.currentTimeMillis();
        for (int j = 0; j < increment; j++) {
            results.add(service.submit(new Callable<Object>() {

                public Object call() throws Exception {
                    return select(conn, Integer.toString(rand.nextInt((fi + 1) * increment)));
                }
            }));
        }
        for (int j = 0; j < increment; j++)
            results.get(j).get();
        readTimes[i] = (System.currentTimeMillis() - startTime);
        System.out.println("read: " + (readTimes[i] / (double) increment));
    }
    conn.close();

    System.out.println();
    System.out.println("iteration read write:");
    for (int i = 0; i < iterations; i++) {
        System.out.print(i);
        System.out.print(" " + readTimes[i] / (double) increment);
        System.out.println(" " + writeTimes[i] / (double) increment);
    }

    System.exit(0);
}

From source file:voldemort.store.mysql.MysqlStorageConfiguration.java

public MysqlStorageConfiguration(VoldemortConfig config) {
    BasicDataSource ds = new BasicDataSource();
    ds.setUrl("jdbc:mysql://" + config.getMysqlHost() + ":" + config.getMysqlPort() + "/"
            + config.getMysqlDatabaseName());
    ds.setUsername(config.getMysqlUsername());
    ds.setPassword(config.getMysqlPassword());
    ds.setDriverClassName("com.mysql.jdbc.Driver");
    this.dataSource = ds;
}

From source file:voldemort.store.mysql.MysqlStorageEngineTest.java

private DataSource getDataSource() {
    BasicDataSource ds = new BasicDataSource();
    ds.setUrl("jdbc:mysql://localhost:3306/test");
    ds.setUsername("root");
    ds.setPassword("");
    ds.setDriverClassName("com.mysql.jdbc.Driver");
    return ds;//from w w w .j  a  va2  s. c  o m
}