Examples of BasicDataSource


Examples of org.apache.commons.dbcp.BasicDataSource

    init();
  }

  private void init() {
    if (dataSource == null) {
      dataSource = new BasicDataSource();
      dataSource.setUsername("gnizr");
      dataSource.setPassword("gnizr");
      dataSource.setUrl("jdbc:mysql://localhost/gnizr_test");
      dataSource.setDriverClassName("com.mysql.jdbc.Driver");
      dataSource.addConnectionProperty("characterEncoding", "UTF-8");
View Full Code Here

Examples of org.apache.commons.dbcp.BasicDataSource

*/
public class MySQLDBExport {
 
  public static void main(String[] args) throws Exception
   
    BasicDataSource dataSource = new BasicDataSource();
    dataSource.setUsername("gnizr");
    dataSource.setPassword("gnizr");
    dataSource.setUrl("jdbc:mysql://localhost/gnizr_db");
    dataSource.setDriverClassName("com.mysql.jdbc.Driver");
   
    IDatabaseConnection dc = new DatabaseConnection(dataSource.getConnection());
    DatabaseConfig config = dc.getConfig();
    config.setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY,
        new MySqlDataTypeFactory());

        // full database export
View Full Code Here

Examples of org.apache.commons.dbcp.BasicDataSource

  private GnizrDao gnizrDBDao;
 
  private void init() {
    if (dataSource == null) {
      dataSource = new BasicDataSource();
      dataSource.setUsername("gnizr");
      dataSource.setPassword("gnizr");
      dataSource.setUrl("jdbc:mysql://localhost/gnizr_test");
      dataSource.setDriverClassName("com.mysql.jdbc.Driver");
      dataSource.addConnectionProperty("characterEncoding", "UTF-8");
View Full Code Here

Examples of org.apache.commons.dbcp.BasicDataSource

  private GnizrDao gnizrDBDao;
 
  private void init() {
    if (dataSource == null) {
      dataSource = new BasicDataSource();
      dataSource.setUsername("gnizr");
      dataSource.setPassword("gnizr");
      dataSource.setUrl("jdbc:mysql://localhost/gnizr_test");
      dataSource.setDriverClassName("com.mysql.jdbc.Driver");
    }
View Full Code Here

Examples of org.apache.commons.dbcp.BasicDataSource

      url.append(enc(e.getValue()));
      if (iter.hasNext()) {
        url.append("&");
      }
    }
    BasicDataSource ds = new BasicDataSource();
    ds.setUrl(url.toString());
    if (user != null) {
      ds.setUsername(user);
    }
    else {
      ds.setUsername(System.getProperty("user.name"));
    }
    if (password != null) {
      ds.setPassword(password);
    }
    PgSqlConnectionFactory factory = new PgSqlConnectionFactory();
    factory.setSail(this);
    factory.setDataSource(ds);
    setBasicDataSource(ds);
View Full Code Here

Examples of org.apache.commons.dbcp.BasicDataSource

        int defaultTransactionIsolation = dataSourceInformation.getDefaultTransactionIsolation();


        if (DataSourceInformation.BASIC_DATA_SOURCE.equals(dsType)) {

            BasicDataSource basicDataSource = new BasicDataSource();
            basicDataSource.setDriverClassName(driver);
            basicDataSource.setUrl(url);

            if (user != null && !"".equals(user)) {
                basicDataSource.setUsername(user);
            }

            if (password != null && !"".equals(password)) {
                basicDataSource.setPassword(password);
            }

            basicDataSource.setMaxActive(dataSourceInformation.getMaxActive());
            basicDataSource.setMaxIdle(dataSourceInformation.getMaxIdle());
            basicDataSource.setMaxWait(dataSourceInformation.getMaxWait());
            basicDataSource.setMinIdle(dataSourceInformation.getMinIdle());
            basicDataSource.setDefaultAutoCommit(dataSourceInformation.isDefaultAutoCommit());
            basicDataSource.setDefaultReadOnly(dataSourceInformation.isDefaultReadOnly());
            basicDataSource.setTestOnBorrow(dataSourceInformation.isTestOnBorrow());
            basicDataSource.setTestOnReturn(dataSourceInformation.isTestOnReturn());
            basicDataSource.setTestWhileIdle(dataSourceInformation.isTestWhileIdle());
            basicDataSource.setMinEvictableIdleTimeMillis(
                    dataSourceInformation.getMinEvictableIdleTimeMillis());
            basicDataSource.setTimeBetweenEvictionRunsMillis(
                    dataSourceInformation.getTimeBetweenEvictionRunsMillis());
            basicDataSource.setNumTestsPerEvictionRun(
                    dataSourceInformation.getNumTestsPerEvictionRun());
            basicDataSource.setMaxOpenPreparedStatements(
                    dataSourceInformation.getMaxOpenPreparedStatements());
            basicDataSource.setAccessToUnderlyingConnectionAllowed(
                    dataSourceInformation.isAccessToUnderlyingConnectionAllowed());
            basicDataSource.setInitialSize(dataSourceInformation.getInitialSize());
            basicDataSource.setPoolPreparedStatements(
                    dataSourceInformation.isPoolPreparedStatements());


            if (defaultTransactionIsolation != -1) {
                basicDataSource.setDefaultTransactionIsolation(defaultTransactionIsolation);
            }

            String defaultCatalog = dataSourceInformation.getDefaultCatalog();
            if (defaultCatalog != null && !"".equals(defaultCatalog)) {
                basicDataSource.setDefaultCatalog(defaultCatalog);
            }

            String validationQuery = dataSourceInformation.getValidationQuery();

            if (validationQuery != null && !"".equals(validationQuery)) {
                basicDataSource.setValidationQuery(validationQuery);
            }

            return basicDataSource;

        } else if (DataSourceInformation.PER_USER_POOL_DATA_SOURCE.equals(dsType)) {
View Full Code Here

Examples of org.apache.commons.dbcp.BasicDataSource

            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

Examples of org.apache.commons.dbcp.BasicDataSource

     * Gets a new DBCP data source.
     *
     * @return A new data source.
     */
    public DataSource getDataSource() {
        BasicDataSource ds = new BasicDataSource();
        ds.setDriverClassName(this.driverName);
        ds.setUsername(this.databaseUserName);
        ds.setPassword(this.databasePassword);
        ds.setUrl(this.jdbcUrl);

        return ds;
    }
View Full Code Here

Examples of org.apache.commons.dbcp.BasicDataSource

                            fake.close();
                        }
                    }
                   
                    // apache basic DS
                    BasicDataSource ds = new BasicDataSource();
                    ds.setDriverClassName(p.getProperty("db.driver"));
                    ds.setUsername(p.getProperty("db.user"));
                    ds.setPassword(p.getProperty("db.pass"));
                    ds.setUrl(p.getProperty("db.url"));
                   
                    DB.datasource = ds;
                    url = ds.getUrl();
                    Connection c = null;
                    try {
                        c = ds.getConnection();
                    } finally {
                        if (c != null) {
                            c.close();
                        }
                    }
View Full Code Here

Examples of org.apache.commons.dbcp.BasicDataSource

    public void tearDown() {
        engine.destroy();
    }

    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;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.