/*
* Distributed as part of c3p0 v.0.9.5.1
*
* Copyright (C) 2015 Machinery For Change, Inc.
*
* Author: Steve Waldman <swaldman@mchange.com>
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of EITHER:
*
* 1) The GNU Lesser General Public License (LGPL), version 2.1, as
* published by the Free Software Foundation
*
* OR
*
* 2) The Eclipse Public License (EPL), version 1.0
*
* You may choose which license to accept if you wish to redistribute
* or modify this work. You may offer derivatives of this work
* under the license you have chosen, or you may provide the same
* choice of license which you have been offered here.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received copies of both LGPL v2.1 and EPL v1.0
* along with this software; see the files LICENSE-EPL and LICENSE-LGPL.
* If not, the text of these licenses are currently available at
*
* LGPL v2.1: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
* EPL v1.0: http://www.eclipse.org/org/documents/epl-v10.php
*
*/
import java.sql.*;
import javax.naming.*;
import javax.sql.DataSource;
/**
* This example shows how to programmatically get and directly use
* an unpooled DataSource
*/
public final class UseJndiDataSource
{
public static void main(String[] argv)
{
try
{
// let a command line arg specify the name we will
// lookup our DataSource.
String jndiName = argv[0];
// Create an InitialContext, and lookup the DataSource in
// the usual way.
//
// We are using the no-arg version of InitialContext's constructor,
// therefore, the jndi environment must be first set via a jndi.properties
// file, System properties, or by some other means.
InitialContext ctx = new InitialContext();
// acquire the DataSource... this is the only c3p0 specific code here
DataSource ds = (DataSource) ctx.lookup( jndiName );
// get hold of a Connection an do stuff, in the usual way
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
try
{
con = ds.getConnection();
stmt = con.createStatement();
rs = stmt.executeQuery("SELECT * FROM foo");
while (rs.next())
System.out.println( rs.getString(1) );
}
finally
{
// i try to be neurotic about ResourceManagement,
// explicitly closing each resource
// but if you are in the habit of only closing
// parent resources (e.g. the Connection) and
// letting them close their children, all
// c3p0 DataSources will properly deal.
attemptClose(rs);
attemptClose(stmt);
attemptClose(con);
}
}
catch (Exception e)
{ e.printStackTrace(); }
}
static void attemptClose(ResultSet o)
{
try
{ if (o != null) o.close();}
catch (Exception e)
{ e.printStackTrace();}
}
static void attemptClose(Statement o)
{
try
{ if (o != null) o.close();}
catch (Exception e)
{ e.printStackTrace();}
}
static void attemptClose(Connection o)
{
try
{ if (o != null) o.close();}
catch (Exception e)
{ e.printStackTrace();}
}
private UseJndiDataSource()
{}
}
没有合适的资源?快使用搜索试试~ 我知道了~
c3p0-0.9.5.2
共230个文件
html:204个
jar:5个
java:4个
5星 · 超过95%的资源 需积分: 41 272 下载量 134 浏览量
2016-04-21
20:01:42
上传
评论
收藏 2.58MB ZIP 举报
温馨提示
c3p0连接池jar包,0.9.5.2版本,包括mchange-commons-java-0.2.11.jar、c3p0-oracle-thin-extras-0.9.5.2.jar、c3p0-0.9.5.2.jar。
资源推荐
资源详情
资源评论
收起资源包目录
c3p0-0.9.5.2 (230个子文件)
RELEASE_NOTES-c3p0-0.9.5.1 1KB
RELEASE_NOTES-c3p0-0.9.2 2KB
CHANGELOG 107KB
stylesheet.css 13KB
stylesheet.css 13KB
index-all.html 1023KB
NewProxyCallableStatement.html 222KB
index.html 180KB
NewProxyResultSet.html 179KB
NewProxyDatabaseMetaData.html 172KB
AbstractPoolBackedDataSource.html 141KB
NewProxyPreparedStatement.html 111KB
C3P0PooledDataSource.html 111KB
C3P0PooledDataSource.html 107KB
AbstractComboPooledDataSource.html 100KB
PooledDataSource.html 89KB
PoolConfig.html 78KB
C3P0PooledDataSourceMBean.html 69KB
WrapperConnectionPoolDataSourceBase.html 68KB
C3P0PooledDataSourceMBean.html 67KB
CloseLoggingComboPooledDataSource.html 65KB
AfterCloseLoggingComboPooledDataSource.html 63KB
NewProxyConnection.html 60KB
ConstructionLoggingComboPooledDataSource.html 60KB
ComboPooledDataSource.html 59KB
NewProxyStatement.html 58KB
PoolBackedDataSourceFactory.html 54KB
BasicResourcePoolFactory.html 51KB
PoolBackedDataSource.html 49KB
JndiRefConnectionPoolDataSource.html 47KB
ResourcePoolFactory.html 45KB
PooledDataSourceManager.html 44KB
overview-tree.html 41KB
WrapperConnectionPoolDataSource.html 39KB
ResourcePool.html 37KB
serialized-form.html 36KB
C3P0PooledConnectionPoolManager.html 33KB
C3P0Defaults.html 31KB
DriverManagerDataSourceBase.html 31KB
PoolBackedDataSourceBase.html 30KB
JndiRefDataSourceBase.html 28KB
PooledDataSourceManagerMBean.html 28KB
FreezableDriverManagerDataSource.html 27KB
DataSources.html 27KB
DriverManagerDataSource.html 26KB
constant-values.html 26KB
C3P0PooledConnectionPool.html 26KB
AbstractConnectionTester.html 25KB
C3P0Config.html 23KB
UnifiedConnectionTester.html 23KB
GooGooStatementCache.html 23KB
DefaultConnectionTester.html 22KB
allclasses-frame.html 22KB
C3P0Registry.html 21KB
C3P0RegistryManager.html 20KB
DriverManagerDataSourceFactory.html 20KB
allclasses-noframe.html 19KB
IsValidOnlyConnectionTester.html 18KB
NewPooledConnection.html 18KB
TestConnectionCustomizer.html 18KB
AbstractConnectionCustomizer.html 17KB
JdbcProxyGenerator.html 17KB
C3P0ConfigUtils.html 16KB
AlwaysFailDataSource.html 16KB
DynamicPooledDataSourceManagerMBean.html 16KB
ActiveManagementCoordinator.html 16KB
AlwaysFailConnectionTester.html 16KB
C3P0ImplUtils.html 16KB
EventSupportingResourcePool.html 16KB
PerConnectionMaxOnlyStatementCache.html 15KB
C3P0PooledConnection.html 15KB
GlobalMaxOnlyStatementCache.html 15KB
C3P0ProxyStatement.html 15KB
FilterDataSource.html 15KB
DoubleMaxStatementCache.html 15KB
ResourcePoolEventSupport.html 15KB
ConnectionTester.html 15KB
GooGooStatementCache.DeathmarchConnectionStatementManager.html 15KB
C3P0ProxyConnection.html 14KB
IsValidOnlyConnectionTester30.html 14KB
IdentityTokenResolvable.html 14KB
deprecated-list.html 14KB
NullManagementCoordinator.html 14KB
GooGooStatementCache.ConnectionStatementManager.html 14KB
package-tree.html 13KB
C3P0RegistryManagerMBean.html 13KB
package-tree.html 13KB
C3P0ImplUtilsParentLoggerGeneratorExtension.html 13KB
ResourcePoolEvent.html 13KB
AuthMaskingProperties.html 13KB
UnsupportedParentLoggerGeneratorExtension.html 13KB
package-summary.html 13KB
CloseReportingConnectionWrapper.html 12KB
StatementEventSupport.html 12KB
CloseLoggingConnectionWrapper.html 12KB
C3P0ConfigXmlUtils.html 12KB
ConnectionCustomizer.html 12KB
ConnectionEventSupport.html 12KB
TestUtils.html 12KB
InitSqlConnectionCustomizer.html 12KB
共 230 条
- 1
- 2
- 3
资源评论
- Tony05052016-09-07可用,非常不错,节省时间
- liuyjava2017-10-11可用,非常不错,节省时间
- Jeelon2017-11-21可以不错。。。。
- DayCodeDay2016-12-08很给力,好用!
- 蓝胖学长2018-03-04很好,学习学习,受教了~!
lion_king_007
- 粉丝: 2
- 资源: 20
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功