/*
* 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.3.bin.zip
共233个文件
html:204个
jar:5个
java:4个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 179 浏览量
2022-01-24
21:28:35
上传
评论
收藏 2.61MB ZIP 举报
温馨提示
c3p0 是一个易于使用的库,用于使用 JNDI 可绑定数据源(包括实现连接和语句池的数据源)扩充传统(基于 DriverManager)的 JDBC 驱动程序,如 jdbc3 规范和 jdbc2 std 扩展所述。
资源推荐
资源详情
资源评论
收起资源包目录
c3p0-0.9.5.3.bin.zip (233个子文件)
RELEASE_NOTES-c3p0-0.9.5.1 1KB
RELEASE_NOTES-c3p0-0.9.2 2KB
RELEASE_NOTES-c3p0-0.9.5.2 259B
RELEASE_NOTES-c3p0-0.9.5.3 1KB
CHANGELOG 107KB
stylesheet.css 13KB
stylesheet.css 13KB
index-all.html 1023KB
NewProxyCallableStatement.html 222KB
index.html 181KB
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
C3P0ConfigXmlUtils.html 13KB
CloseReportingConnectionWrapper.html 12KB
StatementEventSupport.html 12KB
CloseLoggingConnectionWrapper.html 12KB
ConnectionCustomizer.html 12KB
ConnectionEventSupport.html 12KB
共 233 条
- 1
- 2
- 3
资源评论
YunFeiDong
- 粉丝: 173
- 资源: 4045
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 图书商城-JAVA-基于springboot图书商城管理系统设计与实现(毕业论文+开题报告)
- 码头船只货柜-JAVA-基于springBoot码头船只货柜管理系统设计与实现(毕业论文+开题+任务书)
- 基于Verilog实现mips五级流水线CPU设计源码+报告(高分项目)
- 农产品直卖-JAVA-基于springBoot的农产品直卖平台的设计与实现(毕业论文+开题报告)
- 宠物商城-JAVA-基于springBoot的宠物商城网站设计与实现(毕业论文)
- 美食烹饪互动-JAVA-基于springboot技术的美食烹饪互动平台的设计与实现(毕业论文)
- 普通人一生总共能挣多少钱.mp4
- 强制戒色(戒色神器).mp4
- 极乐pro登录即是会员支持下载付费音乐.mp4
- 价值超高的各种【小吃教程】副业摆摊先学上.mp4
- 驾考帮手app 让你全面掌握考试知识.mp4
- C++飞机订票系统源码
- 电商应用-java-基于SpringBoot+Vue的电商应用系统的设计与实现(毕业论文)
- 截图工具PixPin v1.9.5.0正式版.mp4
- 建行开养老金必中58元微信立减金亲测.mp4
- 京东0.01亓撸白象方便面3袋.mp4
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功