Package org.apache.commons.dbcp

Examples of org.apache.commons.dbcp.BasicDataSource


        }

    }

    private DataSource loadUserStoreSpacificDataSoruce() throws UserStoreException {
        BasicDataSource ds = null;
        String url = realmConfig.getUserStoreProperty(JDBCRealmConstants.DRIVER_NAME);
        if (url != null) {
            ds = new BasicDataSource();
            ds.setDriverClassName(url);
            ds.setUrl(realmConfig.getUserStoreProperty(JDBCRealmConstants.URL));
            ds.setUsername(realmConfig.getUserStoreProperty(JDBCRealmConstants.USER_NAME));
            ds.setPassword(realmConfig.getUserStoreProperty(JDBCRealmConstants.PASSWORD));
            ds.setMaxActive(Integer.parseInt(realmConfig
                    .getUserStoreProperty(JDBCRealmConstants.MAX_ACTIVE)));
            ds.setMinIdle(Integer.parseInt(realmConfig
                    .getUserStoreProperty(JDBCRealmConstants.MIN_IDLE)));
            ds.setMaxWait(Integer.parseInt(realmConfig
                    .getUserStoreProperty(JDBCRealmConstants.MAX_WAIT)));
        }
        return ds;
    }
View Full Code Here


    }

    private static DataSource createRealmDataSource(RealmConfiguration realmConfig) {

        dataSource = new BasicDataSource();

        dataSource.setDriverClassName(realmConfig.getRealmProperty(JDBCRealmConstants.DRIVER_NAME));
        dataSource.setUrl(realmConfig.getRealmProperty(JDBCRealmConstants.URL));
        dataSource.setUsername(realmConfig.getRealmProperty(JDBCRealmConstants.USER_NAME));
        dataSource.setPassword(realmConfig.getRealmProperty(JDBCRealmConstants.PASSWORD));
View Full Code Here

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

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

        realm = new DefaultRealm();
        InputStream inStream = this.getClass().getClassLoader().getResource(
View Full Code Here

        txm.commit();
    }

    protected DataSource getDataSource() {
        if (externalDB) {
            BasicDataSource ds = new BasicDataSource();
            try {
                ds.setDriverClassName("com.mysql.jdbc.Driver");
                ds.setUsername("sa");
                ds.setPassword("sa");
                ds.setUrl("jdbc:mysql://localhost/bpmsdbJunit");
                this.ds = ds;
            } catch (Exception ex) {
                ex.printStackTrace();
                System.out.println("######### Couldn't get External connection! #############");
            }
        }
        if (ds == null) {
            EmbeddedXADataSource ds = new EmbeddedXADataSource();
            ds.setCreateDatabase("create");
            ds.setDatabaseName("target/testdb");
            ds.setUser("sa");
            ds.setPassword("");
            this.ds = ds;
        }
        return ds;
    }
View Full Code Here

    private DataSource initDataSource() {
        String path = CarbonUtils.getCarbonConfigDirPath() + File.separator + "bam-publisher.properties";
        Properties props = new Properties();
        try {
            props.load(new FileInputStream(path));
            BasicDataSource dataSource = new BasicDataSource();
            dataSource.setDriverClassName(props.getProperty("driver"));
            dataSource.setUrl(props.getProperty("url"));
            dataSource.setUsername(props.getProperty("username"));
            dataSource.setPassword(props.getProperty("password"));

            String validationQuery = props.getProperty("validationQuery");
            if (validationQuery != null) {
                dataSource.setValidationQuery(validationQuery);
            }

            String maxActive = props.getProperty("maxActive");
            if (maxActive != null) {
                dataSource.setMaxActive(Integer.parseInt(maxActive));
            }

            String initialSize = props.getProperty("initialSize");
            if (initialSize != null) {
                dataSource.setInitialSize(Integer.parseInt(initialSize));
            }

            String maxIdle = props.getProperty("maxIdle");
            if (maxIdle != null) {
                dataSource.setMaxIdle(Integer.parseInt(maxIdle));
            }

            log.info("Created new data source to: " + dataSource.getUrl());
            return dataSource;

        } catch (IOException e) {
            log.error("Error while loading publisher DB configuration from: " + path, e);
            return null;
View Full Code Here

            throw new SynapseException(msg);
        }

        if (dataSource instanceof BasicDataSource) {

            BasicDataSource basicDataSource = (BasicDataSource) dataSource;
            int numActive = basicDataSource.getNumActive();
            int numIdle = basicDataSource.getNumIdle();
            String connectionId = Integer.toHexString(con.hashCode());

            DBPoolView dbPoolView = getDbPoolView();
            if (dbPoolView != null) {
                dbPoolView.setNumActive(numActive);
View Full Code Here

        </dbConfig>
     */
    private void initDataSource(OMElement dbConfigEle) throws BillingException {
        // initializing the data source and load the database configurations
        Iterator dbConfigChildIt = dbConfigEle.getChildElements();
        dataSource = new BasicDataSource();
       
        while (dbConfigChildIt.hasNext()) {
           
            OMElement dbConfigChildEle = (OMElement) dbConfigChildIt.next();
            if (new QName(BillingConstants.CONFIG_NS, BillingConstants.DBCONFIG_URL,
View Full Code Here

        return null;

    }

    private DataSource buildDataSource(DatabaseConfiguration config) {
        BasicDataSource basicDataSource = new BasicDataSource();
        basicDataSource.setUrl(config.getDbUrl().trim());
        basicDataSource.setDriverClassName(config.getDriverName().trim());
        basicDataSource.setUsername(config.getUserName().trim());
        basicDataSource.setPassword(config.getPassword().trim());
        basicDataSource.setMaxActive(config.getMaxActive());
        basicDataSource.setMaxIdle(config.getMaxIdle());
        basicDataSource.setMaxWait(config.getMaxWait());
        basicDataSource.setMinIdle(config.getMinIdle());
        basicDataSource.setValidationQuery(config.getValidationQuery());

        return basicDataSource;

    }
View Full Code Here

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

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

        DatabaseCreator creator = new DatabaseCreator(ds);
        creator.createRegistryDatabase();
        tenantMan = new JDBCTenantManager(ds, "super.com");
    }
View Full Code Here

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

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

        DatabaseCreator creator = new DatabaseCreator(ds);
        creator.createRegistryDatabase();
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.