Package com.mchange.v2.c3p0

Examples of com.mchange.v2.c3p0.DataSources


    // "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

   private ComboPooledDataSource pooledDataSource;

   @Override
   public void start(ConnectionFactoryConfig config, ClassLoader classLoader) throws CacheLoaderException {
      logFileOverride(classLoader);
      pooledDataSource = new ComboPooledDataSource();
      pooledDataSource.setProperties(new Properties());
      try {
         pooledDataSource.setDriverClass(config.getDriverClass()); //loads the jdbc driver
      } catch (PropertyVetoException e) {
         log.errorInstantiatingJdbcDriver(config.getDriverClass(), e);
View Full Code Here

      }
      else {
         throw new CacheLoaderException("ConnectionFactoryConfiguration passed in must be an instance of " +
               "PooledConnectionFactoryConfiguration");
      }
      pooledDataSource = new ComboPooledDataSource();
      pooledDataSource.setProperties(new Properties());
      try {
         /* Since c3p0 does not throw an exception when it fails to load a driver we attempt to do so here
          * Also, c3p0 does not allow specifying a custom classloader, so use c3p0's
          */
 
View Full Code Here

                "DBPool '" + dbURL + "' could not be created: " +
                "Max connections must be greater than zero!");
        }

       
        datasource = new ComboPooledDataSource();
        try {
            datasource.setDriverClass(dbDriver);
        } catch (PropertyVetoException e) {
            throw new SchedulerException("Problem setting driver class name on datasource: " + e.getMessage(), 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);
                    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

TOP

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

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.