当前位置: 首页>>代码示例>>Java>>正文


Java BasicDataSource.setUrl方法代码示例

本文整理汇总了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);
}
 
开发者ID:javamelody,项目名称:javamelody,代码行数:20,代码来源:TestJdbcWrapper.java

示例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;
}
 
开发者ID:jkardynia,项目名称:mvc-spring-hibernate,代码行数:11,代码来源:HibernateConfig.java

示例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);
}
 
开发者ID:javamelody,项目名称:javamelody,代码行数:60,代码来源:TestJdbcWrapper.java


注:本文中的org.apache.tomcat.dbcp.dbcp.BasicDataSource.setUrl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。