Package com.mchange.v2.c3p0

Examples of com.mchange.v2.c3p0.ComboPooledDataSource


 
  // Declare a datasource that has pooling capabilities
  @Bean
  public DataSource dataSource() {
    try {
      ComboPooledDataSource ds = new ComboPooledDataSource();
      ds.setDriverClass(env.getRequiredProperty("app.jdbc.driverClassName"));
      ds.setJdbcUrl(env.getRequiredProperty("app.jdbc.url"));
      ds.setUser(env.getRequiredProperty("app.jdbc.username"));
      ds.setPassword(env.getRequiredProperty("app.jdbc.password"));
      ds.setAcquireIncrement(5);
      ds.setIdleConnectionTestPeriod(60);
      ds.setMaxPoolSize(100);
      ds.setMaxStatements(50);
      ds.setMinPoolSize(10);
      return ds;
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
View Full Code Here


                        }
                    }

                    System.setProperty("com.mchange.v2.log.MLog", "com.mchange.v2.log.FallbackMLog");
                    System.setProperty("com.mchange.v2.log.FallbackMLog.DEFAULT_CUTOFF_LEVEL", "OFF");
                    ComboPooledDataSource ds = new ComboPooledDataSource();
                    ds.setDriverClass(p.getProperty("db.driver"));
                    ds.setJdbcUrl(p.getProperty("db.url"));
                    ds.setUser(p.getProperty("db.user"));
                    ds.setPassword(p.getProperty("db.pass"));
                    ds.setAcquireRetryAttempts(10);
                    ds.setCheckoutTimeout(Integer.parseInt(p.getProperty("db.pool.timeout", "5000")));
                    ds.setBreakAfterAcquireFailure(false);
                    ds.setMaxPoolSize(Integer.parseInt(p.getProperty("db.pool.maxSize", "30")));
                    ds.setMinPoolSize(Integer.parseInt(p.getProperty("db.pool.minSize", "1")));
                    ds.setMaxIdleTimeExcessConnections(Integer.parseInt(p.getProperty("db.pool.maxIdleTimeExcessConnections", "0")));
                    ds.setIdleConnectionTestPeriod(10);
                    ds.setTestConnectionOnCheckin(true);
                   
                    // This check is not required, but here to make it clear that nothing changes for people
                    // that don't set this configuration property. It may be safely removed.
                    if(p.getProperty("db.isolation") != null) {
                        ds.setConnectionCustomizerClassName(play.db.DBPlugin.PlayConnectionCustomizer.class.getName());
                    }
                   
                    DB.datasource = ds;
                    url = ds.getJdbcUrl();
                    Connection c = null;
                    try {
                        c = ds.getConnection();
                    } finally {
                        if (c != null) {
                            c.close();
                        }
                    }
                    Logger.info("Connected to %s", ds.getJdbcUrl());

                }

                DB.destroyMethod = p.getProperty("db.destroyMethod", "");
View Full Code Here

            out.println("Datasource:");
            out.println("~~~~~~~~~~~");
            out.println("(not yet connected)");
            return sw.toString();
        }
        ComboPooledDataSource datasource = (ComboPooledDataSource) DB.datasource;
        out.println("Datasource:");
        out.println("~~~~~~~~~~~");
        out.println("Jdbc url: " + datasource.getJdbcUrl());
        out.println("Jdbc driver: " + datasource.getDriverClass());
        out.println("Jdbc user: " + datasource.getUser());
        out.println("Jdbc password: " + datasource.getPassword());
        out.println("Min pool size: " + datasource.getMinPoolSize());
        out.println("Max pool size: " + datasource.getMaxPoolSize());
        out.println("Initial pool size: " + datasource.getInitialPoolSize());
        out.println("Checkout timeout: " + datasource.getCheckoutTimeout());
        return sw.toString();
    }
View Full Code Here

        }
       
        if (DB.datasource == null) {
            return true;
        } else {
            ComboPooledDataSource ds = (ComboPooledDataSource) DB.datasource;
            if (!p.getProperty("db.driver").equals(ds.getDriverClass())) {
                return true;
            }
            if (!p.getProperty("db.url").equals(ds.getJdbcUrl())) {
                return true;
            }
            if (!p.getProperty("db.user", "").equals(ds.getUser())) {
                return true;
            }
            if (!p.getProperty("db.pass", "").equals(ds.getPassword())) {
                return true;
            }
        }

        if (!p.getProperty("db.destroyMethod", "").equals(DB.destroyMethod)) {
View Full Code Here

        toInt(ps.getProperty("maxPoolSize")), toInt(ps.getProperty("minPoolSize")), toInt(ps.getProperty("initialPoolSize")),
        toInt(ps.getProperty("maxIdleTime")),toInt(ps.getProperty("acquireIncrement")));
  }
 
  public boolean start() {
    dataSource = new ComboPooledDataSource();
    dataSource.setJdbcUrl(jdbcUrl);
    dataSource.setUser(user);
    dataSource.setPassword(password);
    try {dataSource.setDriverClass(driverClass);}
    catch (PropertyVetoException e) {dataSource = null; System.err.println("C3p0Plugin start error"); throw new RuntimeException(e);}
View Full Code Here

    return jpaVendorAdapter;
  }

  @Bean
  public DataSource dataSource() {
    final ComboPooledDataSource dataSource = new ComboPooledDataSource();
    // All options set from the externally loaded properties file!
    return dataSource;
  }
View Full Code Here

    // "LPS");
    try {
      // databaseTester = new MySQLJdbcDatabaseTester(
      // PropertiesUtil.JDBC_DRIVER, jdbc_url,
      // PropertiesUtil.JDBC_USERNAME, PropertiesUtil.JDBC_PASSWD);
      ComboPooledDataSource ds = new ComboPooledDataSource();
      ds.setDriverClass(PropertiesUtil.JDBC_DRIVER);
      ds.setUser(PropertiesUtil.JDBC_USERNAME);
      ds.setPassword(PropertiesUtil.JDBC_PASSWD);
      ds.setJdbcUrl(jdbc_url);

      if (PropertiesUtil.JDBC_DRIVER.toLowerCase().contains("mysql")) {
        logger.info("use mysql datasource tester.");
        jdbc_url = PropertiesUtil.JDBC_URL
            + "&sessionVariables=FOREIGN_KEY_CHECKS=0";
        ds.setJdbcUrl(jdbc_url);
        databaseTester = new MySQLDataSourceDatabaseTester(ds);
      } else if (PropertiesUtil.JDBC_DRIVER.toLowerCase().contains(
          "oracle")) {
        logger.info("use oracle datasource tester.");
        databaseTester = new OracleDataSourceDatabaseTester(ds,
View Full Code Here

  }

  private static DataSource createDataSource() throws IOException {
    Properties properties = new Properties();
    properties.load(ConfigurationDbImplTest.class.getResourceAsStream("/jdbc.properties"));
    ComboPooledDataSource result = new ComboPooledDataSource();
    try {
      result.setDriverClass(properties.getProperty("jdbc.driverClassName"));
    } catch (PropertyVetoException e) {
      throw new RuntimeException("Cannot access JDBC Driver: org.h2.Driver", e);
    }
    result.setJdbcUrl(properties.getProperty("jdbc.url"));
    result.setUser(properties.getProperty("jdbc.username"));
    result.setPassword(properties.getProperty("jdbc.password"));
    result.setMinPoolSize(10);
    result.setMaxPoolSize(300);
    result.setInitialPoolSize(10);
    result.setAcquireIncrement(5);
    result.setMaxStatements(0);
    result.setIdleConnectionTestPeriod(60);
    result.setAcquireRetryAttempts(30);
    result.setBreakAfterAcquireFailure(false);
    result.setTestConnectionOnCheckout(false);
    return result;
  }
View Full Code Here

      throw new RuntimeException("Cannot get dataset.", e);
    }
  }

  private static DataSource createDataSource(Properties jdbcProperties) {
    ComboPooledDataSource dataSource = new ComboPooledDataSource();
    try {
      dataSource.setDriverClass(jdbcProperties.getProperty(JdbcConstants.JDBC_DRIVER));
    } catch (PropertyVetoException e) {
      throw new RuntimeException("Cannot create C3P0 data source", e);
    }
    dataSource.setJdbcUrl(jdbcProperties.getProperty(JdbcConstants.JDBC_URL));
    dataSource.setUser(jdbcProperties.getProperty(JdbcConstants.JDBC_USERNAME));
    dataSource.setPassword(jdbcProperties.getProperty(JdbcConstants.JDBC_PASSWORD));
    return dataSource;
  }
View Full Code Here

*/
public class C3P0DataSourceCreator extends AbstractDataSourceCreator {

  @Override
  protected DataSource createDataSource() {
    return new ComboPooledDataSource();
  }
View Full Code Here

TOP

Related Classes of com.mchange.v2.c3p0.ComboPooledDataSource

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.