Package org.apache.commons.dbcp

Examples of org.apache.commons.dbcp.BasicDataSource


        String dbFolder = "target/BasicJDBCDatabaseTest";
        if ((new File(dbFolder)).exists()) {
            deleteDir(new File(dbFolder));
        }

        BasicDataSource ds = new BasicDataSource();
        ds.setDriverClassName(UserCoreTestConstants.DB_DRIVER);
        ds.setUrl(dbUrl);
        DatabaseCreator creator = new DatabaseCreator(ds);
        creator.createRegistryDatabase();

        realm = new DefaultRealm();
        InputStream inStream = this.getClass().getClassLoader().getResource(
                JDBCRealmTest.JDBC_TEST_USERMGT_XML).openStream();
        RealmConfiguration realmConfig = TestRealmConfigBuilder
                .buildRealmConfigWithJDBCConnectionUrl(inStream, TEST_URL);
        realm.init(realmConfig, ClaimTestUtil.getClaimTestData(), ClaimTestUtil
                .getProfileTestData(), 0);
        ds.close();
    }
View Full Code Here


                .getProfileTestData(), 0);
        ds.close();
    }

    public void testAuthorizationClearence() throws Exception{
        BasicDataSource ds = new BasicDataSource();
        ds.setDriverClassName(UserCoreTestConstants.DB_DRIVER);
        ds.setUrl("jdbc:h2:target/clear-resources/WSO2CARBON_DB_CLEAR");
        ds.setUsername("wso2carbon");
        ds.setPassword("wso2carbon");

        realm = new DefaultRealm();

        Map<String, Object> properties = new HashMap<String, Object>();
        properties.put(UserCoreConstants.DATA_SOURCE, ds);
View Full Code Here

         String dbFolder =  "target/permTreetest";
        if ((new File(dbFolder)).exists()) {
            deleteDir(new File(dbFolder));
        }

      BasicDataSource ds = new BasicDataSource();
        ds.setDriverClassName(UserCoreTestConstants.DB_DRIVER);
        ds.setUrl(TEST_URL);

        DatabaseCreator creator = new DatabaseCreator(ds);
        creator.createRegistryDatabase();

        realm = new DefaultRealm();
View Full Code Here

        String dbFolder = "target/advjdbcrotest";
        if ((new File(dbFolder)).exists()) {
            deleteDir(new File(dbFolder));
        }

        BasicDataSource ds = new BasicDataSource();
        ds.setDriverClassName(UserCoreTestConstants.DB_DRIVER);
        ds.setUrl("jdbc:h2:target/advjdbcrotest/CARBON_TEST");

        DatabaseCreator creator = new DatabaseCreator(ds);
        creator.createRegistryDatabase();
       
        this.addIntialData(ds);
View Full Code Here

        String dbFolder = "target/PermissionTest";
        if ((new File(dbFolder)).exists()) {
            deleteDir(new File(dbFolder));
        }

        BasicDataSource ds = new BasicDataSource();
        // ds.setDriverClassName("org.apache.derby.jdbc.EmbeddedDriver");
        // ds.setUrl("jdbc:derby:target/databasetest/CARBON_TEST;create=true");

        ds.setDriverClassName(UserCoreTestConstants.DB_DRIVER);
        ds.setUrl(TEST_URL);
        DatabaseCreator creator = new DatabaseCreator(ds);
        creator.createRegistryDatabase();

        realm = new DefaultRealm();
View Full Code Here

   
    private DataSource delegate;
   
    public TransientDatasource() {
       
        BasicDataSource basicDataSource = new BasicDataSource();
        basicDataSource.setMaxActive(1);
        basicDataSource.setInitialSize(1);
        basicDataSource.setDriverClassName("org.hsqldb.jdbcDriver");
        basicDataSource.setUrl("jdbc:hsqldb:mem:adhommemds");
        basicDataSource.setMaxIdle(0);
       
        this.delegate = basicDataSource;

    }
View Full Code Here

        if (testQuery != null) {
            testWhileIdle = true;
        }
       
        BasicDataSource dataSource = new BasicDataSource();
        dataSource.setUsername(getUser());
        dataSource.setPassword(getPassword());
        dataSource.setDriverClassName(getDriver());
        dataSource.setUrl(getURL());
        dataSource.setDefaultAutoCommit(false);
        dataSource.setPoolPreparedStatements(true);

        // configure pooling
        dataSource.setMaxActive(getMaxActive());
        dataSource.setMaxIdle(getMaxIdle());

        dataSource.setMaxWait(60 * 1000);
        // force the pool to timeout to avoid deadlocks

        dataSource.setValidationQuery(testQuery);
        dataSource.setTestOnBorrow(getTestBeforeUse());
        dataSource.setTimeBetweenEvictionRunsMillis(evictionIntervalMS);
        dataSource.setMinEvictableIdleTimeMillis(minIdleTimeMS);
        dataSource.setTestWhileIdle(testWhileIdle);

        _dataSource = dataSource;
    }
View Full Code Here

public class DBCPConnectionManager implements ConnectionManager {
    private Map cache = new HashMap();

    public Connection getConnection(Database db) throws SQLException {
        Long id = db.getId();
        BasicDataSource datasource = (BasicDataSource) cache.get(id);
        if(datasource == null){
            String driver = db.getDriver();
            String url = db.getUrl();
            String username = db.getUsername();
            String password = db.getPassword();
           
            datasource = new BasicDataSource();
            datasource.setDriverClassName(driver);
            datasource.setUrl(url);
            datasource.setUsername(username);
            datasource.setPassword(password);
            cache.put(id, datasource);
        }
        return datasource.getConnection();
    }
View Full Code Here

    DataSource ds = null;
    try {
      InitialContext ctx = new InitialContext();
      ds = (DataSource) ctx.lookup(GlobalContext.DATASOURCE_JNDI_NAME);
    } catch (Exception e) {     
      BasicDataSource bds = new BasicDataSource();
      bds.setDriverClassName(GlobalContext.JDBC_DRIVERCLASSNAME);
      bds.setUrl(GlobalContext.JDBC_URL);
      bds.setUsername(GlobalContext.JDBC_USERNAME);
      bds.setPassword(GlobalContext.JDBC_PASSWORD);
      bds.setValidationQuery(GlobalContext.JDBC_VALIDATION_QUERY);
      bds.setMaxActive(GlobalContext.JDBC_MAX_ACTIVE);
      bds.setMaxIdle(GlobalContext.JDBC_MAX_IDLE);
      bds.setMaxWait(GlobalContext.JDBC_MAX_WAIT);
      ds = bds;
    }
    return ds;
  }
View Full Code Here

      ds = (javax.sql.DataSource) ctx.lookup(jndiName);
     
    } else if (this.getConnectionFactory().getClass() == JDBCConnectionFactory.class) {
     
      JDBCConnectionFactory cf = (JDBCConnectionFactory) this.getConnectionFactory();
      BasicDataSource bds = new BasicDataSource();
      bds.setDriverClassName(cf.getDriverClass());
      bds.setUrl(cf.getConnectionString());
      bds.setUsername(cf.getUserId());
      bds.setPassword(cf.getPassword());
      ds = bds;
     
    }
   
    String actualSqlStatement = evaluateContent(instance, this.getSqlStatement()).toString().trim();
View Full Code Here

TOP

Related Classes of org.apache.commons.dbcp.BasicDataSource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.