Package com.mchange.v2.c3p0

Examples of com.mchange.v2.c3p0.UnifiedConnectionTester


  @Override
  public void forcePasswordUpdate(String password) throws ApplicationException {
    // we know it's ComboPooledDataSource, as we define it in applicationContext.xml
    // this is the primary reason for using C3P0 rather than Apache DBCP, since it
    // doesn't support password updates.
    ComboPooledDataSource dataSource = getDataSource();
    ComboPooledDataSource initialDataSource =
        (ComboPooledDataSource) initialJdbcTemplate.getDataSource();
    dataSource.setPassword(password);
    initialDataSource.setPassword(password);
    try {
      dataSource.softResetDefaultUser();
      initialDataSource.softResetDefaultUser();
    } catch (SQLException e) {
      throw new ApplicationException("Password update failed!", e);
    }
    try {
      initialJdbcTemplate.execute("select 1");
View Full Code Here


   *
   * Use that fact to parse host name and port number out of jdbc url,
   * which is on form jdbc:postgresql://localhost:5432/musiccabinet.
   */
  private void parseJDBCURL() {
    ComboPooledDataSource ds = getDataSource();

    String url = ds.getJdbcUrl();
    int i1 = url.indexOf("://") + 3;
    int i2 = url.indexOf(":", i1);
    int i3 = url.indexOf("/", i2);
   
    host = url.substring(i1, i2);
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

   private ComboPooledDataSource pooledDataSource;

   @Override
   public void start(ConnectionFactoryConfig config, ClassLoader classLoader) throws CacheLoaderException {
      logFileOverride(classLoader);
      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

        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

TOP

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

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.