Package com.mchange.v2.c3p0

Examples of com.mchange.v2.c3p0.ComboPooledDataSource


    public void testRefDerefRoundTrip()
    {
  try
      {
    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


            {
                Config.DATABASE_MAX_CONNECTIONS = 2;
                _log.warning("at least " + Config.DATABASE_MAX_CONNECTIONS + " db connections are required.");
            }

      _source = new ComboPooledDataSource();
      _source.setAutoCommitOnClose(true);

      _source.setInitialPoolSize(10);
      _source.setMinPoolSize(10);
      _source.setMaxPoolSize(Config.DATABASE_MAX_CONNECTIONS);
View Full Code Here

     * @return Retorna un valor verdadero en caso de que
     * se inicialice correctamente la piscina de conexiones.
     */
    protected static boolean initialize(){
        try {
            cpds = new ComboPooledDataSource();
            cpds.setCheckoutTimeout(Constants.dbTimeout);
            cpds.setDriverClass("com.mysql.jdbc.Driver");
            String sT;
            if ( Shared.storeIp != null ){
                sT = "jdbc:mysql://" + Shared.storeIp + "/" +
View Full Code Here

       
    }
    protected static boolean initializeProfit(){
        try {
            cpdsProfit = new ComboPooledDataSource();
            cpdsProfit.setCheckoutTimeout(Constants.dbTimeout);
            cpdsProfit.setDriverClass("com.microsoft.sqlserver.jdbc.SQLServerDriver");
            String url = "jdbc:sqlserver://" + Shared.getConfig("serverSQLServerProfitAdd") + ":" + Shared.getConfig("portSqlServer") + ";DatabaseName=" + Shared.getConfig("profitDatabase");
            cpdsProfit.setJdbcUrl(url);
            cpdsProfit.setUser(Shared.getFileConfig("dbSqlServerUser"));
View Full Code Here

        return cpdsProfit != null;
    }

    protected static boolean reinitializeOffline(){
        try {
            cpds = new ComboPooledDataSource();
            cpds.setDriverClass("com.mysql.jdbc.Driver");
            String sT = "jdbc:mysql://" + Shared.getFileConfig("ServerMirror") + "/" +
                            Shared.getFileConfig("mirrorDbName");
            cpds.setJdbcUrl(sT);
            cpds.setUser(Shared.getFileConfig("mirrordbUser"));
View Full Code Here

        }

        System.out.println("[" + Shared.now() + "] Driver de conexiones " + Shared.lineNumber() " Replica normal de tabla");

        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() " 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

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.