本文整理汇总了Java中org.apache.tomcat.dbcp.dbcp.BasicDataSource.setUrl方法的典型用法代码示例。如果您正苦于以下问题:Java BasicDataSource.setUrl方法的具体用法?Java BasicDataSource.setUrl怎么用?Java BasicDataSource.setUrl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.tomcat.dbcp.dbcp.BasicDataSource
的用法示例。
在下文中一共展示了BasicDataSource.setUrl方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testRewrapDataSource
import org.apache.tomcat.dbcp.dbcp.BasicDataSource; //导入方法依赖的package包/类
/** Test.
* @throws Exception e */
@Test
public void testRewrapDataSource() throws Exception {
final BasicDataSource tomcatDataSource = new BasicDataSource();
tomcatDataSource.setUrl(H2_DATABASE_URL);
rewrapDataSource(tomcatDataSource);
final org.apache.commons.dbcp.BasicDataSource dbcpDataSource = new org.apache.commons.dbcp.BasicDataSource();
dbcpDataSource.setUrl(H2_DATABASE_URL);
rewrapDataSource(dbcpDataSource);
final org.apache.tomcat.dbcp.dbcp2.BasicDataSource tomcat2DataSource = new org.apache.tomcat.dbcp.dbcp2.BasicDataSource();
tomcat2DataSource.setUrl(H2_DATABASE_URL);
rewrapDataSource(tomcat2DataSource);
final org.apache.commons.dbcp2.BasicDataSource dbcp2DataSource = new org.apache.commons.dbcp2.BasicDataSource();
dbcp2DataSource.setUrl(H2_DATABASE_URL);
rewrapDataSource(dbcp2DataSource);
final DataSource dataSource = createNiceMock(DataSource.class);
rewrapDataSource(dataSource);
}
示例2: restDataSource
import org.apache.tomcat.dbcp.dbcp.BasicDataSource; //导入方法依赖的package包/类
@Bean
public DataSource restDataSource() {
BasicDataSource dataSource = new BasicDataSource();
dataSource.setDriverClassName(env.getProperty("jdbc.driverClassName"));
dataSource.setUrl(env.getProperty("jdbc.url"));
dataSource.setUsername(env.getProperty("jdbc.user"));
dataSource.setPassword(env.getProperty("jdbc.pass"));
return dataSource;
}
示例3: testCreateDataSourceProxy
import org.apache.tomcat.dbcp.dbcp.BasicDataSource; //导入方法依赖的package包/类
/** Test.
* @throws Exception e */
@Test
public void testCreateDataSourceProxy() throws Exception {
// on fait le ménage au cas où TestMonitoringSpringInterceptor ait été exécuté juste avant
cleanUp();
assertTrue("getBasicDataSourceProperties0",
JdbcWrapper.getBasicDataSourceProperties().isEmpty());
assertEquals("getMaxConnectionCount0", -1, JdbcWrapper.getMaxConnectionCount());
final org.apache.tomcat.jdbc.pool.DataSource tomcatJdbcDataSource = new org.apache.tomcat.jdbc.pool.DataSource();
tomcatJdbcDataSource.setUrl(H2_DATABASE_URL);
tomcatJdbcDataSource.setDriverClassName("org.h2.Driver");
tomcatJdbcDataSource.setMaxActive(123);
final DataSource tomcatJdbcProxy = jdbcWrapper.createDataSourceProxy("test2",
tomcatJdbcDataSource);
assertNotNull("createDataSourceProxy1", tomcatJdbcProxy);
tomcatJdbcProxy.getConnection().close();
assertFalse("getBasicDataSourceProperties1",
JdbcWrapper.getBasicDataSourceProperties().isEmpty());
assertEquals("getMaxConnectionCount1", 123, JdbcWrapper.getMaxConnectionCount());
final org.apache.commons.dbcp.BasicDataSource dbcpDataSource = new org.apache.commons.dbcp.BasicDataSource();
dbcpDataSource.setUrl(H2_DATABASE_URL);
dbcpDataSource.setMaxActive(456);
final DataSource dbcpProxy = jdbcWrapper.createDataSourceProxy(dbcpDataSource);
assertNotNull("createDataSourceProxy2", dbcpProxy);
assertFalse("getBasicDataSourceProperties2",
JdbcWrapper.getBasicDataSourceProperties().isEmpty());
assertEquals("getMaxConnectionCount2", 456, JdbcWrapper.getMaxConnectionCount());
final BasicDataSource tomcatDataSource = new BasicDataSource();
tomcatDataSource.setUrl(H2_DATABASE_URL);
tomcatDataSource.setMaxActive(789);
final DataSource tomcatProxy = jdbcWrapper.createDataSourceProxy("test", tomcatDataSource);
assertNotNull("createDataSourceProxy3", tomcatProxy);
assertNotNull("getLogWriter2", tomcatProxy.getLogWriter());
tomcatProxy.getConnection().close();
assertFalse("getBasicDataSourceProperties3",
JdbcWrapper.getBasicDataSourceProperties().isEmpty());
assertEquals("getMaxConnectionCount3", 789, JdbcWrapper.getMaxConnectionCount());
final org.apache.commons.dbcp2.BasicDataSource dbcp2DataSource = new org.apache.commons.dbcp2.BasicDataSource();
dbcp2DataSource.setUrl(H2_DATABASE_URL);
dbcp2DataSource.setMaxTotal(456);
final DataSource dbcp2Proxy = jdbcWrapper.createDataSourceProxy(dbcp2DataSource);
assertNotNull("createDataSourceProxy2b", dbcp2Proxy);
final org.apache.tomcat.dbcp.dbcp2.BasicDataSource tomcat2DataSource = new org.apache.tomcat.dbcp.dbcp2.BasicDataSource();
tomcat2DataSource.setUrl(H2_DATABASE_URL);
tomcat2DataSource.setMaxTotal(789);
final DataSource tomcat2Proxy = jdbcWrapper.createDataSourceProxy("test",
tomcat2DataSource);
assertNotNull("createDataSourceProxy3b", tomcat2Proxy);
final DataSource dataSource2 = new MyDataSource(tomcatDataSource);
jdbcWrapper.createDataSourceProxy(dataSource2);
}