Package com.mchange.v2.c3p0.impl

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


        }

        System.out.println("[" + Shared.now() + "] Driver de conexiones " + Shared.lineNumber() " sincronizar montos en dinero");

        if ( !mirrorConnected ){ // just once =D
            cpdsMirror = new ComboPooledDataSource();
            cpdsMirror.setDriverClass("com.mysql.jdbc.Driver");
            String sT = "jdbc:mysql://" + Shared.getFileConfig("ServerMirror") + "/" + Shared.getFileConfig("mirrorDbName");
            cpdsMirror.setJdbcUrl(sT);
            cpdsMirror.setUser(Shared.getFileConfig("mirrordbUser"));
            cpdsMirror.setPassword(Shared.getFileConfig("mirrordbPassword"));
View Full Code Here


            return;
        }

        System.out.println("[" + Shared.now() + "] Driver de conexiones " + Shared.lineNumber() " Actualizar stock desde espejo");
        if ( !mirrorConnected ){ // just once =D
            cpdsMirror = new ComboPooledDataSource();
            cpdsMirror.setDriverClass("com.mysql.jdbc.Driver");
            String sT = "jdbc:mysql://" + Shared.getFileConfig("ServerMirror") + "/" + Shared.getFileConfig("mirrorDbName");
            cpdsMirror.setJdbcUrl(sT);
            cpdsMirror.setUser(Shared.getFileConfig("mirrordbUser"));
            cpdsMirror.setPassword(Shared.getFileConfig("mirrordbPassword"));
View Full Code Here

        }

        System.out.println("[" + Shared.now() + "] Driver de conexiones " + Shared.lineNumber() " Borrando espejo");

        if ( !mirrorConnected ){ // just once =D
            cpdsMirror = new ComboPooledDataSource();
            cpdsMirror.setDriverClass("com.mysql.jdbc.Driver");
            String sT = "jdbc:mysql://" + Shared.getFileConfig("ServerMirror") + "/" + Shared.getFileConfig("mirrorDbName");
            cpdsMirror.setJdbcUrl(sT);
            cpdsMirror.setUser(Shared.getFileConfig("mirrordbUser"));
            cpdsMirror.setPassword(Shared.getFileConfig("mirrordbPassword"));
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

    {
  try
      {
        cpds.setIdentityToken("poop"); //simulate a never-before-seen data source, so it's a new registration on deserialization
    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

    {
  try
      {
        cpds.setIdentityToken("scoop"); //simulate a never-before-seen data source, so it's a new registration on deserialization
    Reference ref = cpds.getReference();
    ComboPooledDataSource unpickled = (ComboPooledDataSource) ReferenceableUtils.referenceToObject( ref, null, null, null );
    assertTrue( "Marshalled and unmarshalled DataSources should have the same properties!",
          BeansUtils.equalsByAccessibleProperties( cpds, unpickled, EXCLUDE_PROPS ) );
      }
  catch (Exception e)
      {
View Full Code Here

        // set the JMX domain for the C3P0
        C3P0CustomManagementCoordinator.setJmxDomainOnce(config.getJmxDomain());

        // create a new instance of the c3p0 datasource
        ComboPooledDataSource cpds = new ComboPooledDataSource(true);

        // set properties
        try {
            // set required properties
            cpds.setDriverClass(config.getDriver());
            cpds.setUser(config.getUsername());
            cpds.setPassword(config.getPassword());
            cpds.setJdbcUrl(config.getUrl());

            // set optional properties
            cpds.setDataSourceName(config.getName());
            cpds.setMinPoolSize(config.getMinPoolSize());
            cpds.setMaxPoolSize(config.getMaxPoolSize());
            // we'll set the initial pool size to the minimum size
            cpds.setInitialPoolSize(config.getMinPoolSize());

            // set the validation query
            cpds.setPreferredTestQuery(config.getValidationQuery());

            // amount of time (in ms) to wait for getConnection() to succeed
            cpds.setCheckoutTimeout((int)config.getCheckoutTimeout());

            // checkin validation
            cpds.setTestConnectionOnCheckin(config.getValidateOnCheckin());

            // checkout validation
            cpds.setTestConnectionOnCheckout(config.getValidateOnCheckout());

            // amount of time to wait to validate connections
            // NOTE: in seconds
            int seconds = (int)(config.getValidateIdleConnectionTimeout()/1000);
            cpds.setIdleConnectionTestPeriod(seconds);

            // set idleConnectionTimeout
            // NOTE: in seconds
            seconds = (int)(config.getIdleConnectionTimeout()/1000);
            cpds.setMaxIdleTimeExcessConnections(seconds);

            // set activeConnectionTimeout
            seconds = (int)(config.getActiveConnectionTimeout()/1000);
            cpds.setUnreturnedConnectionTimeout(seconds);

            if (config.getDebug()) {
                cpds.setDebugUnreturnedConnectionStackTraces(true);
            } else {
                cpds.setDebugUnreturnedConnectionStackTraces(false);
            }

            // properties I think aren't valid for c3p0
            // defines how many times c3p0 will try to acquire a new Connection from the database before giving up.
            cpds.setAcquireRetryAttempts(10);

        } catch (PropertyVetoException e) {
            throw new SQLConfigurationException("Property was vetoed during configuration", e);
        }
View Full Code Here

    private ThreadCategory log() {
        return ThreadCategory.getInstance(getClass());
    }

    private void initializePool(String jdbcUrl, String driverClass, String user, String password) throws PropertyVetoException, SQLException {
        m_pool = new ComboPooledDataSource();
        m_pool.setPassword(password);
        m_pool.setUser(user);
        m_pool.setJdbcUrl(jdbcUrl);
        m_pool.setDriverClass(driverClass);
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

      }
      else {
         throw new PersistenceException("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

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.