Search in sources :

Example 16 with ComboPooledDataSource

use of com.mchange.v2.c3p0.jacksonTest.ComboPooledDataSource in project activityinfo by bedatadriven.

the class TestConnectionProvider method openConnection.

static synchronized Connection openConnection() throws SQLException {
    if (POOL == null) {
        try {
            if (!Boolean.getBoolean("skipDatabaseInit")) {
                initializeDatabase();
            }
            POOL = new ComboPooledDataSource();
            POOL.setDriverClass("com.mysql.jdbc.Driver");
            POOL.setJdbcUrl(connectionUrl(DATABASE_NAME));
            POOL.setUser(USERNAME);
            POOL.setPassword(PASSWORD);
            POOL.setMinPoolSize(2);
            POOL.setAcquireIncrement(1);
            POOL.setMaxPoolSize(5);
            POOL.setUnreturnedConnectionTimeout(120);
            POOL.setDebugUnreturnedConnectionStackTraces(true);
        } catch (Exception e) {
            throw new Error("Could not open connection to " + DATABASE_NAME, e);
        }
    }
    return POOL.getConnection();
}
Also used : ComboPooledDataSource(com.mchange.v2.c3p0.ComboPooledDataSource) SQLException(java.sql.SQLException) LiquibaseException(liquibase.exception.LiquibaseException)

Example 17 with ComboPooledDataSource

use of com.mchange.v2.c3p0.jacksonTest.ComboPooledDataSource in project eap-additional-testsuite by jboss-set.

the class JaxbResourceDeserializationSecurityCheck method getComboPooledDataSource.

@GET
@Path("mchange")
@Produces(MediaType.APPLICATION_JSON)
public Response getComboPooledDataSource() throws RemoteException, IOException {
    ComboPooledDataSource obj = new ComboPooledDataSource();
    ObjectMapper mapper = new ObjectMapper();
    mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
    // do various things, perhaps:
    String objJsonString = mapper.writeValueAsString(obj);
    return Response.ok().entity(objJsonString).build();
}
Also used : ComboPooledDataSource(com.mchange.v2.c3p0.jacksonTest.ComboPooledDataSource) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 18 with ComboPooledDataSource

use of com.mchange.v2.c3p0.jacksonTest.ComboPooledDataSource in project crawler4j by yasserg.

the class PgsqlTest method testPostgresRepository.

@Test
public void testPostgresRepository() throws Exception {
    String jdbcurl = String.format("jdbc:postgresql://%s:%d/crawler4j", docker.containers().container("db").port(5432).getIp(), port);
    String maxPagesToFetch = "20";
    String numberOfCrawler = "1";
    SampleLauncher.main(new String[] { maxPagesToFetch, jdbcurl, numberOfCrawler });
    ComboPooledDataSource pool = getTestPool(jdbcurl);
    int count = 0;
    try (Connection connection = pool.getConnection()) {
        ResultSet rs = connection.prepareStatement("SELECT COUNT (1) FROM webpage;").executeQuery();
        rs.next();
        count = rs.getInt(1);
        rs.close();
    }
    pool.close();
    Assert.assertThat(count, Matchers.greaterThan(0));
}
Also used : ComboPooledDataSource(com.mchange.v2.c3p0.ComboPooledDataSource) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) Test(org.junit.Test)

Example 19 with ComboPooledDataSource

use of com.mchange.v2.c3p0.jacksonTest.ComboPooledDataSource in project crawler4j by yasserg.

the class PgsqlTest method getTestPool.

private ComboPooledDataSource getTestPool(String jdbcurl) throws PropertyVetoException {
    ComboPooledDataSource comboPooledDataSource = new ComboPooledDataSource();
    comboPooledDataSource.setDriverClass("org.postgresql.Driver");
    comboPooledDataSource.setJdbcUrl(jdbcurl);
    comboPooledDataSource.setUser("crawler4j");
    comboPooledDataSource.setPassword("crawler4j");
    comboPooledDataSource.setMaxPoolSize(1);
    comboPooledDataSource.setMinPoolSize(1);
    comboPooledDataSource.setInitialPoolSize(1);
    return comboPooledDataSource;
}
Also used : ComboPooledDataSource(com.mchange.v2.c3p0.ComboPooledDataSource)

Example 20 with ComboPooledDataSource

use of com.mchange.v2.c3p0.jacksonTest.ComboPooledDataSource in project ignite by apache.

the class TcpDiscoveryJdbcIpFinderSelfTest method ipFinder.

/**
 * {@inheritDoc}
 */
@Override
protected TcpDiscoveryJdbcIpFinder ipFinder() throws Exception {
    TcpDiscoveryJdbcIpFinder finder = new TcpDiscoveryJdbcIpFinder();
    assert finder.isShared() : "IP finder should be shared by default.";
    dataSrc = new ComboPooledDataSource();
    dataSrc.setDriverClass("org.h2.Driver");
    if (initSchema)
        dataSrc.setJdbcUrl("jdbc:h2:mem:./test");
    else {
        dataSrc.setJdbcUrl("jdbc:h2:mem:jdbc_ipfinder_not_initialized_schema");
        finder.setInitSchema(false);
    }
    finder.setDataSource(dataSrc);
    return finder;
}
Also used : ComboPooledDataSource(com.mchange.v2.c3p0.ComboPooledDataSource)

Aggregations

ComboPooledDataSource (com.mchange.v2.c3p0.ComboPooledDataSource)69 PropertyVetoException (java.beans.PropertyVetoException)16 SQLException (java.sql.SQLException)13 Connection (java.sql.Connection)7 Test (org.junit.Test)7 Bean (org.springframework.context.annotation.Bean)7 Properties (java.util.Properties)5 DataSource (javax.sql.DataSource)5 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 ComboPooledDataSource (com.mchange.v2.c3p0.jacksonTest.ComboPooledDataSource)4 ResultSet (java.sql.ResultSet)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 Path (javax.ws.rs.Path)3 Produces (javax.ws.rs.Produces)3 DbRuntimeException (cn.hutool.db.DbRuntimeException)2 JsonMappingException (com.fasterxml.jackson.databind.JsonMappingException)2 Duration (de.invesdwin.util.time.duration.Duration)2 PreparedStatement (java.sql.PreparedStatement)2 EntityManagerFactory (javax.persistence.EntityManagerFactory)2