Search in sources :

Example 61 with ComboPooledDataSource

use of com.mchange.v2.c3p0.jacksonTest.ComboPooledDataSource in project uavstack by uavorg.

the class C3P0HookProxy method collectDBPoolMetrics.

@SuppressWarnings("rawtypes")
@Override
public void collectDBPoolMetrics(MonitorElement clientElem) {
    Set dsList = C3P0Registry.getPooledDataSources();
    if (dsList == null || dsList.size() == 0) {
        return;
    }
    /**
     * Step 2: 匹配对应的jdbc url
     */
    for (Object ds : dsList) {
        if (!ComboPooledDataSource.class.isAssignableFrom(ds.getClass())) {
            continue;
        }
        ComboPooledDataSource pds = (ComboPooledDataSource) ds;
        String jdbcURL = pds.getJdbcUrl();
        /**
         * 匹配客户端应用
         */
        MonitorElementInstance inst = this.matchElemInstance(clientElem, jdbcURL);
        if (inst == null) {
            continue;
        }
        collectDataSourceStat(inst, pds);
    }
}
Also used : ComboPooledDataSource(com.mchange.v2.c3p0.ComboPooledDataSource) Set(java.util.Set) MonitorElementInstance(com.creditease.monitor.captureframework.spi.MonitorElementInstance)

Example 62 with ComboPooledDataSource

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

the class C3p0Plugin method start.

public boolean start() {
    if (isStarted)
        return true;
    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);
    }
    dataSource.setMaxPoolSize(maxPoolSize);
    dataSource.setMinPoolSize(minPoolSize);
    dataSource.setInitialPoolSize(initialPoolSize);
    dataSource.setMaxIdleTime(maxIdleTime);
    dataSource.setAcquireIncrement(acquireIncrement);
    isStarted = true;
    return true;
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) ComboPooledDataSource(com.mchange.v2.c3p0.ComboPooledDataSource)

Example 63 with ComboPooledDataSource

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

the class JaxbProviderDeserializationSecurityCheck3TestCase method testMChangeV2C3p0.

@Test
public void testMChangeV2C3p0() throws Exception {
    String result = performCall("rest/jaxb/mchange");
    try {
        ComboPooledDataSource jaxbModel = new ObjectMapper().configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false).readValue(result, ComboPooledDataSource.class);
        Assert.fail("Should prevente json deserialization because of security reasons.");
    } catch (JsonMappingException e) {
        Assert.assertTrue("Should prevente json deserialization because of security reasons.", e.getMessage().contains("Illegal type"));
    }
}
Also used : ComboPooledDataSource(com.mchange.v2.c3p0.jacksonTest.ComboPooledDataSource) JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ATTest(org.jboss.eap.additional.testsuite.annotations.ATTest) Test(org.junit.Test)

Example 64 with ComboPooledDataSource

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

the class JaxbResourceDeserializationSecurityCheck3 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 65 with ComboPooledDataSource

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

the class JaxbProviderDeserializationSecurityCheckTestCase method testMChangeV2C3p0.

@ATTest({ "modules/testcases/jdkAll/Wildfly/jaxrs/src/main/java#13.0.0.Alpha1", "modules/testcases/jdkAll/WildflyRelease-17.0.0.Final/jaxrs/src/main/java", "modules/testcases/jdkAll/Eap71x/jaxrs/src/main/java#7.1.3", "modules/testcases/jdkAll/Eap71x-Proposed/jaxrs/src/main/java#7.1.3", "modules/testcases/jdkAll/Eap7/jaxrs/src/main/java#7.1.2", "modules/testcases/jdkAll/Eap72x/jaxrs/src/main/java", "modules/testcases/jdkAll/Eap72x-Proposed/jaxrs/src/main/java" })
@Test
public void testMChangeV2C3p0() throws Exception {
    String result = performCall("rest/jaxb/mchange");
    try {
        ComboPooledDataSource jaxbModel = new ObjectMapper().configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false).readValue(result, ComboPooledDataSource.class);
        Assert.fail("Should prevente json deserialization because of security reasons.");
    } catch (JsonMappingException e) {
        Assert.assertTrue("Should prevente json deserialization because of security reasons.", e.getMessage().contains("Illegal type"));
    }
}
Also used : ComboPooledDataSource(com.mchange.v2.c3p0.jacksonTest.ComboPooledDataSource) JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ATTest(org.jboss.eap.additional.testsuite.annotations.ATTest) Test(org.junit.Test) ATTest(org.jboss.eap.additional.testsuite.annotations.ATTest)

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