Package com.mchange.v2.c3p0.impl

Examples of com.mchange.v2.c3p0.impl.C3P0ImplUtils


   private ComboPooledDataSource pooledDataSource;

   @Override
   public void start(ConnectionFactoryConfig config) throws CacheLoaderException {
      logFileOverride();
      pooledDataSource = new ComboPooledDataSource();
      pooledDataSource.setProperties(new Properties());
      try {
         pooledDataSource.setDriverClass(config.getDriverClass()); //loads the jdbc driver
      } catch (PropertyVetoException e) {
         String message = "Error while instatianting JDBC driver: '" + config.getDriverClass();
View Full Code Here


public class OracleMonitoringDbDialectTest extends MonitoringDbDialectTestBase{

  @Override
  void intit() {
 
    ComboPooledDataSource datasource_oracle = new ComboPooledDataSource();
    try {
      datasource_oracle.setDriverClass("oracle.jdbc.OracleDriver");
      datasource_oracle.setJdbcUrl("jdbc:oracle:thin:COPPER2/COPPER2@localhost:1521:HM");
      datasource_oracle.setMinPoolSize(1);
      datasource_oracle.setMaxPoolSize(8);
      datasource_oracle.setConnectionTesterClassName("de.scoopgmbh.copper.db.utility.oracle.c3p0.OracleConnectionTester");
      datasource_oracle.setConnectionCustomizerClassName("de.scoopgmbh.copper.db.utility.oracle.c3p0.OracleConnectionCustomizer");
      datasource_oracle.setIdleConnectionTestPeriod(15);
    } catch (PropertyVetoException e1) {
      throw new RuntimeException(e1);
    }
    this.datasource=datasource_oracle;
   
View Full Code Here

   */
  public SqlDao(final Properties properties) {
    super(properties);
   
    // Attempt to create the DataSource.
    ComboPooledDataSource comboPooledDataSource =
      new ComboPooledDataSource();
   
    // Set the properties from the properties file (the ones that begin
    // with "c3p0").
    comboPooledDataSource.setProperties(properties);

    // Attempt to load the driver to be used to connect to the database.
    if(properties.containsKey(KEY_PROPERTY_DATABASE_DRIVER)) {
      try {
        comboPooledDataSource
          .setDriverClass(
            properties.getProperty(KEY_PROPERTY_DATABASE_DRIVER));
      }
      catch(PropertyVetoException e) {
        LOGGER.log(Level.SEVERE, "The driver was rejected.", e);
        throw new IllegalStateException("The driver was rejected.", e);
      }
    }
    // Otherwise, we may error out.
    else {
      LOGGER
        .log(
          Level.SEVERE,
          "For SQL database connections, a driver must be " +
            "specified.");
    }
   
    // If the JDBC URL was given, use that.
    if(properties.containsKey(KEY_PROPERTY_DATABASE_JDBC_URL)) {
      comboPooledDataSource
        .setJdbcUrl(
          properties.getProperty(KEY_PROPERTY_DATABASE_JDBC_URL));
    }
    // Otherwise, ask the specific implementation for a default URL.
    else {
      comboPooledDataSource.setJdbcUrl(getJdbcUrl());
    }
   
    // Set the username and password.
    comboPooledDataSource.setUser(getDatabaseUsername());
    comboPooledDataSource.setPassword(getDatabasePassword());
   
    // Save the data source.
    dataSource = comboPooledDataSource;
   
    // Create the JDBC template from the data source.
View Full Code Here

        @Override
        protected ComboPooledDataSource setupDataSourcePool( DataSourceConfigurationValue config )
                throws Exception
        {
            ComboPooledDataSource pool = new ComboPooledDataSource();

            Class.forName( config.driver().get() );
            pool.setDriverClass( config.driver().get() );
            pool.setJdbcUrl( config.url().get() );

            if ( !config.username().get().equals( "" ) ) {
                pool.setUser( config.username().get() );
                pool.setPassword( config.password().get() );
            }

            if ( config.minPoolSize().get() != null ) {
                pool.setMinPoolSize( config.minPoolSize().get() );
            }
            if ( config.maxPoolSize().get() != null ) {
                pool.setMaxPoolSize( config.maxPoolSize().get() );
            }
            if ( config.loginTimeoutSeconds().get() != null ) {
                pool.setLoginTimeout( config.loginTimeoutSeconds().get() );
            }
            if ( config.maxConnectionAgeSeconds().get() != null ) {
                pool.setMaxIdleTime( config.maxConnectionAgeSeconds().get() );
            }
            if ( config.validationQuery().get() != null ) {
                pool.setPreferredTestQuery( config.validationQuery().get() );
            }

            String props = config.properties().get();
            String[] properties = props.split( "," );
            Properties poolProperties = new Properties();
            for ( String property : properties ) {
                if ( property.trim().length() > 0 ) {
                    String[] keyvalue = property.trim().split( "=" );
                    poolProperties.setProperty( keyvalue[0], keyvalue[1] );
                }
            }
            pool.setProperties( poolProperties );

            return pool;
        }
View Full Code Here

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

TOP

Related Classes of com.mchange.v2.c3p0.impl.C3P0ImplUtils

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.