List of usage examples for org.apache.commons.dbcp BasicDataSource getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:com.alibaba.druid.benckmark.pool.PoolPerformanceTest.java
@Test public void test_dbcp() throws Exception { final BasicDataSource dataSource = new BasicDataSource(); dataSource.setInitialSize(initialSize); dataSource.setMaxActive(maxActive);// w w w. j av a 2s . com dataSource.setMinIdle(minPoolSize); dataSource.setMaxIdle(maxPoolSize); dataSource.setPoolPreparedStatements(true); dataSource.setDriverClassName(driverClass); dataSource.setUrl(jdbcUrl); dataSource.setPoolPreparedStatements(true); dataSource.setUsername(user); dataSource.setPassword(password); dataSource.setValidationQuery("SELECT 1"); dataSource.setTestOnBorrow(false); System.out.println(dataSource.getClass().getSimpleName()); for (int i = 0; i < loopCount; ++i) { p0(dataSource, "dbcp", threadCount); } System.out.println(); dataSource.close(); TestDriver.instance.reset(); }
From source file:org.apache.openejb.assembler.classic.DataSourceDefinitionPlaceHolderTest.java
private void check(final DataSource ds) throws NoSuchFieldException, IllegalAccessException { assertNotNull(ds);/*from ww w .j av a 2 s.c o m*/ assertThat(ds, instanceOf(BasicDataSource.class)); final BasicDataSource bds = (BasicDataSource) ds; assertEquals("sa", bds.getUsername()); assertEquals("", bds.getPassword()); final Field fieldDs = bds.getClass().getDeclaredField("ds"); fieldDs.setAccessible(true); final JDBCDataSource realDs = (JDBCDataSource) fieldDs.get(bds); assertEquals("jdbc:hsqldb:mem:superDS", realDs.getUrl()); assertEquals("sa", realDs.getUser()); }