Package com.mchange.v2.c3p0

Examples of com.mchange.v2.c3p0.C3P0ProxyStatement


                        }
                    }

                    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

        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 static ComboPooledDataSource staticDS = null;
   private static synchronized DataSource getDataSource(String url) {
     if (staticDS == null) {
        staticDS = new ComboPooledDataSource();
        try {
           Class.forName(DB_DRIVER_CLASS).newInstance();
           staticDS.setDriverClass(DB_DRIVER_CLASS);
        } catch (Exception e) {
           throw new RuntimeException("Error loading database driver: "+e.getMessage());
View Full Code Here

    this.credentials = credentials;
  }

  @Override
  public final ComboPooledDataSource get() {
    ComboPooledDataSource dataSource = new ComboPooledDataSource();

    try {

      dataSource.setDriverClass(credentials.getDriverClass());
      dataSource.setJdbcUrl(credentials.getUrl());
      dataSource.setUser(credentials.getUser());
      dataSource.setPassword(credentials.getPassword());

      configureDataSource(dataSource);

    } catch (PropertyVetoException e) {
View Full Code Here

      {
        Config.DATABASE_MAX_CONNECTIONS = 2;
        _log.warning("A minimum of " + Config.DATABASE_MAX_CONNECTIONS + " db connections are required.");
      }
     
      _source = new ComboPooledDataSource();
      _source.setAutoCommitOnClose(true);
     
      _source.setInitialPoolSize(10);
      _source.setMinPoolSize(10);
      _source.setMaxPoolSize(Math.max(10, Config.DATABASE_MAX_CONNECTIONS));
View Full Code Here

            String username = p.getProperty(KEY_DB_CONNECTION_USERNAME);
            String password = p.getProperty(KEY_DB_CONNECTION_PASSWORD);

            System.setProperty("com.mchange.v2.c3p0.management.ManagementCoordinator", "com.mchange.v2.c3p0.management.NullManagementCoordinator");

            ComboPooledDataSource cpds = new ComboPooledDataSource(connectionName);
      cpds.setDriverClass(driver);
            cpds.setJdbcUrl(url);
      cpds.setUser(username);
      cpds.setPassword(password);
     
      cpds.setAutoCommitOnClose(autoCommit);
     
      cpds.setMaxPoolSize(Integer.parseInt(maxPoolSize));
      cpds.setMinPoolSize(Integer.parseInt(minPoolSize));
      cpds.setAcquireIncrement(Integer.parseInt(acquireIncrement));
      cpds.setInitialPoolSize(Integer.parseInt(initialPoolSize));
      cpds.setMaxIdleTime(Integer.parseInt(maxIdleTime));

            connectionPoolDataSourcesMap.put(connectionName, cpds);
            log.debug("created ds for " + connectionName + " with properties: " + c3p0props);
    } catch (Throwable e) {
      log.error("Failed to create data source for " + connectionName + " with properties: " + c3p0props + ": " + e.getMessage());
View Full Code Here

//                     0,
//                     100 );

    //ds_unpooled = DataSources.unpooledDataSource(jdbc_url, username, password);
    //ds_pooled = DataSources.pooledDataSource( ds_unpooled );
      ds_unpooled = new DriverManagerDataSource();

       //DataSource ds_unpooled_screwy = C3P0TestUtils.unreliableCommitDataSource( ds_unpooled );
       //ds_pooled = DataSources.pooledDataSource( ds_unpooled_screwy );

//     PoolConfig pc = new PoolConfig();
View Full Code Here

      usage();
  */
 
  try
      {
    DriverManagerDataSource dmds = new DriverManagerDataSource();
    //dmds.setJdbcUrl( jdbcUrl );
    //dmds.setUser( username );
    //dmds.setPassword( password );
    try { drop( dmds ); }
    catch (Exception e)
View Full Code Here

TOP

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

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.