Package com.mchange.v2.c3p0

Examples of com.mchange.v2.c3p0.ComboPooledDataSource


        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


   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 DataSource createDataSource(Object databaseKey)
    {
        String databaseName = databaseKey.toString();
        ComboPooledDataSource dataSource = new ComboPooledDataSource();
        try
        {
            dataSource.setDriverClass(driver);
        }
        catch (PropertyVetoException e)
        {
            String msg = "Could not create data source with driver class '" + driver + "' for '" + databaseName + "'.";
            logger.error(msg, e);
            throw new DataSourceCreationException(msg, e);
        }
        dataSource.setJdbcUrl(url + databaseName);
        dataSource.setUser(username);
        dataSource.setPassword(password);
        return dataSource;
    }
View Full Code Here

    return new DatabaseData(dbDialect, datasource_default);
  }
 
  DatabaseData setupOracleDatabase(WorkflowRepository workflowRepository, LoggingStatisticCollector runtimeStatisticsCollector){

    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);
    }

    final OracleDialect oracleDialect = new OracleDialect();
View Full Code Here

   * @param args
   * @throws Exception
   */
  public static void main(String[] args) throws Exception {
    final IdFactory idFactory = new JdkRandomUUIDFactory();
    final ComboPooledDataSource dataSource = new ComboPooledDataSource();
    dataSource.setDriverClass("oracle.jdbc.OracleDriver");
    dataSource.setJdbcUrl("jdbc:oracle:thin:COPPER2/COPPER2@localhost:1521:orcl11g");
    dataSource.setMinPoolSize(1);
    dataSource.setMaxPoolSize(1);
   
    PrintStream ps = System.out; // new PrintStream(new File("C:\\perf-test-results.log"));

//    test(dataSource, idFactory, createByteArray(16), createByteArray(256), ps);
//    test(dataSource, idFactory, createByteArray(16), createByteArray(256), ps);
View Full Code Here

    }

    public void init () throws ConfigurationException
    {
        _logger.info("initializing...");
        pooledDS = new ComboPooledDataSource();

        try
        {
            pooledDS.setDriverClass(Configuration.getStoreDriver());
            pooledDS.setJdbcUrl(Configuration.getStoreUrl());
View Full Code Here

  /** 内部保存的连接池引用, 用于释放资源 */
  private ComboPooledDataSource ds;

  @Override
  protected DataSource getDataSource() throws Exception {
    ds = new ComboPooledDataSource();
    // 当连接池中的连接耗尽的时候c3p0一次同时获取的连接数
    ds.setAcquireIncrement(5);
    // 如果连接失败重试连接的间隔时间
    ds.setAcquireRetryDelay(60);
    // 初始化时获取的连接数
View Full Code Here

        usage();
   
    if (! jdbc_url.startsWith("jdbc:") )
        usage();
           
    ComboPooledDataSource cpds = new ComboPooledDataSource();
    cpds.setJdbcUrl( jdbc_url );
    cpds.setUser( username );
    cpds.setPassword( password );
      cpds.setMaxPoolSize( 10 );
//      cpds.setUsesTraditionalReflectiveProxies( true );
       
    C3P0ProxyConnection conn = (C3P0ProxyConnection) cpds.getConnection();
    Method toStringMethod = Object.class.getMethod("toString", new Class[]{});
    Method identityHashCodeMethod = System.class.getMethod("identityHashCode", new Class[] {Object.class});
    System.out.println("rawConnection.toString() -> " +
           conn.rawConnectionOperation(toStringMethod, C3P0ProxyConnection.RAW_CONNECTION, new Object[]{}));
    Integer ihc = (Integer) conn.rawConnectionOperation(identityHashCodeMethod, null, new Object[]{C3P0ProxyConnection.RAW_CONNECTION});
    System.out.println("System.identityHashCode( rawConnection ) -> " + Integer.toHexString( ihc.intValue() ));

    C3P0ProxyStatement stmt = (C3P0ProxyStatement) conn.createStatement();
    System.out.println("rawStatement.toString() -> " +
           stmt.rawStatementOperation(toStringMethod, C3P0ProxyStatement.RAW_STATEMENT, new Object[]{}));
    Integer ihc2 = (Integer) stmt.rawStatementOperation(identityHashCodeMethod, null, new Object[]{C3P0ProxyStatement.RAW_STATEMENT});
    System.out.println("System.identityHashCode( rawStatement ) -> " + Integer.toHexString( ihc2.intValue() ));

    conn.close()

      for (int i = 0; i < 10; ++i)
          {
        C3P0ProxyConnection check = null;
        try
            {
          check = (C3P0ProxyConnection) cpds.getConnection();
          //System.err.println( TestUtils.samePhysicalConnection( conn, check ) );
          System.err.println( TestUtils.physicalConnectionIdentityHashCode( check ) == ihc.intValue() );
            }
        finally
            { /* if (check != null) check.close(); */ }
View Full Code Here

    }

    public static synchronized DataSource getInstance() {
        if (instance == null) {
            boolean debug = ApplicationContext.getInstance().isDebug();
            ComboPooledDataSource comboPooledDataSource = new ComboPooledDataSource();

            comboPooledDataSource.setJdbcUrl(properties.getProperty("database.url"));
            comboPooledDataSource.setUser(properties.getProperty("database.user"));
            comboPooledDataSource.setPassword(properties.getProperty("database.password"));
            comboPooledDataSource.setCheckoutTimeout(60000);
            comboPooledDataSource.setIdleConnectionTestPeriod(60);
            comboPooledDataSource.setMaxStatementsPerConnection(128);

            if (debug) {
                comboPooledDataSource.setInitialPoolSize(1);
            } else {
                comboPooledDataSource.setInitialPoolSize(4);
            }

            comboPooledDataSource.setMaxPoolSize(4);
            comboPooledDataSource.setPreferredTestQuery("SET time_zone='" + Configuration.getTimeZone() + "'");

            instance = comboPooledDataSource;
        }

        return instance;
View Full Code Here

    public void testSerializationRoundTrip()
    {
  try
      {
    byte[] pickled = SerializableUtils.toByteArray(cpds);
    ComboPooledDataSource unpickled = (ComboPooledDataSource) SerializableUtils.fromByteArray( pickled );
    assertTrue( "Marshalled and unmarshalled DataSources should have the same properties!",
          BeansUtils.equalsByAccessibleProperties( cpds, unpickled, EXCLUDE_PROPS ) );
      }
  catch (Exception e)
      {
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.