Package com.jolbox.bonecp

Examples of com.jolbox.bonecp.BoneCP


    }
  }

  @Test(expectedExceptions = {BlockingOperation.class })
  public void testBlocking() throws SQLException {
    final BoneCP bcp = new BoneCP(createConfig());
    BlockingOperation.off();
    try {
      final Connection h1 = bcp.getConnection();
      assertNotNull(h1);
      final Connection h2 = bcp.getConnection();
      assertNotNull(h2);
      final Connection h3 = bcp.getConnection();
      assertNotNull(h3);
      bcp.getConnection();
      fail();
    } finally {
      BlockingOperation.on();
    }
  }
View Full Code Here


            config.setPartitionCount(1);

            config.setUsername(H4J.getConfig().get("storage.user"));
            config.setPassword(H4J.getConfig().get("storage.password"));

            pool = new BoneCP(config);

            H4J.getLogger(StorePool.class.getName()).info("Storage Pool loaded successfully!");
        } catch (Exception ex) {
            H4J.getLogger(StorePool.class.getName()).error(ex.getMessage());
            System.exit(0);
View Full Code Here

    expect(mockConfig.isDisableConnectionTracking()).andReturn(true).anyTimes();
    expect(mockConfig.getConnectionHook()).andReturn(hookClass).anyTimes();
    replay(mockConfig);
 
    // once for no release threads, once with release threads....
    poolClass = new BoneCP(mockConfig);
  }
View Full Code Here

    expect(mockConfig.getConnectionHook()).andReturn(hook).anyTimes();
    expect(mockConfig.clone()).andReturn(mockConfig).anyTimes();
   
    replay(mockConfig);
   
    poolClass = new BoneCP(mockConfig)
   
    poolClass.getConnection().close();
    poolClass.close();
   
    reset(mockConfig);
    expect(mockConfig.getPartitionCount()).andReturn(1).anyTimes();
    expect(mockConfig.getMaxConnectionsPerPartition()).andReturn(5).anyTimes();
    expect(mockConfig.getMinConnectionsPerPartition()).andReturn(5).anyTimes();
    expect(mockConfig.getIdleConnectionTestPeriodInMinutes()).andReturn(10000L).anyTimes();
    expect(mockConfig.getUsername()).andReturn(CommonTestUtils.username).anyTimes();
    expect(mockConfig.getPassword()).andReturn(CommonTestUtils.password).anyTimes();
    expect(mockConfig.getReleaseHelperThreads()).andReturn(0).anyTimes();
    expect(mockConfig.getConnectionHook()).andReturn(hook).anyTimes();
    expect(mockConfig.isDisableConnectionTracking()).andReturn(true).anyTimes();
    expect(mockConfig.getJdbcUrl()).andReturn("something-bad").anyTimes();
    replay(mockConfig);
    try{
      poolClass = new BoneCP(mockConfig);
      // should throw an exception
    } catch (Exception e){
      // do nothing
    }
   
View Full Code Here

    expect(mockConfig.clone()).andReturn(mockConfig).anyTimes();
   
    replay(mockConfig);
   
    try{
      poolClass = new BoneCP(mockConfig)
      poolClass.getConnection();
    } catch (Exception e){
      // do nothing
    }
    assertEquals(1, hookClass.fail);
View Full Code Here

      }
    }).once();
    driver.setConnection(mockConnection);
    replay(mockConfig, mockPreparedStatement, mockConnection);
   
      poolClass = new BoneCP(mockConfig)
      Connection con = poolClass.getConnection();
      con.prepareStatement("").execute();
     
    reset(mockPreparedStatement, mockConnection);
    poolClass.close();
View Full Code Here

      expect(mockConnection.prepareStatement("")).andReturn(mockPreparedStatement).anyTimes();
      expect(mockPreparedStatement.execute()).andThrow(new SQLException("reason", "1234")).once();
      driver.setConnection(mockConnection);
      replay(mockConfig, mockPreparedStatement, mockConnection);
     
        poolClass = new BoneCP(mockConfig)
        Connection con = poolClass.getConnection();
        try{
          con.prepareStatement("").execute();
          fail("Should throw exception");
        } catch (Exception e){
View Full Code Here

    expect(mockConnection.prepareStatement("")).andReturn(mockPreparedStatement).anyTimes();
    expect(mockPreparedStatement.execute()).andThrow(new SQLException("reason", "8999")).once();
    driver.setConnection(mockConnection);
    replay(mockConfig, mockPreparedStatement, mockConnection);
   
      poolClass = new BoneCP(mockConfig)
      Connection con = poolClass.getConnection();
      try{
        con.prepareStatement("").execute();
        fail("Should throw exception");
      } catch (Exception e){
View Full Code Here

    config.setMinConnectionsPerPartition(pool_size);
    config.setMaxConnectionsPerPartition(pool_size);
    config.setPartitionCount(1);
    config.setAcquireIncrement(5);
    config.setDisableConnectionTracking(true);
    BoneCP dsb = new BoneCP(config);

    long start = System.currentTimeMillis();
    for (int i=0; i < MAX_CONNECTIONS; i++){
      Connection conn = dsb.getConnection();
      conn.close();
    }
    long end = (System.currentTimeMillis() - start);
    //    System.out.println("BoneCP Single thread benchmark: "+end);


    dsb.shutdown();
    return end;

  }
View Full Code Here

    config.setMinConnectionsPerPartition(pool_size);
    config.setMaxConnectionsPerPartition(pool_size);
    config.setPartitionCount(1);
    config.setAcquireIncrement(5);
   
    BoneCP dsb = new BoneCP(config);

    Connection conn = dsb.getConnection();

    long start = System.currentTimeMillis();
    for (int i=0; i< MAX_CONNECTIONS; i++){
      Statement st = conn.prepareStatement(TEST_QUERY);
      st.close();
    }
    conn.close();

    long end = (System.currentTimeMillis() - start);
//    System.out.println("BoneCP PreparedStatement Single thread benchmark: "+end);
//    results.add("BoneCP (1 partitions), "+end);
    // dispose of pool
    dsb.shutdown();
//    results.add("");
    return end;
  }
View Full Code Here

TOP

Related Classes of com.jolbox.bonecp.BoneCP

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.