<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<!-- saved from url=(0047)http://www.misuland.com/HTML/1173153579316.html -->
<HTML xmlns="http://www.w3.org/1999/xhtml"><HEAD><TITLE>jakarta commons-dbcp --米鼠网</TITLE>
<META http-equiv=Content-Type content="text/html; charset=GBK">
<META content=开源,java,it业内,linux,数据库,软件外包,项目外包,定制软件,定制开发,软件需求,威客,维客
name=KEYWords>
<META
content=it新闻,开源信息,技术新闻,开源新闻,黑客新闻,安全信息,编程,病毒,流氓软件,程序员,软件公司,软件工作室,开发团队,软件外包,项目外包,定制软件,外包服务,威客,维客,私活
name=DEscription>
<META content=all name=Robots>
<META http-equiv=windows-Target content=_top>
<STYLE type=text/css>BODY {
FONT-SIZE: 12px; MARGIN: 0px
}
</STYLE>
<LINK href="jakarta commons-dbcp --米鼠网.files/mishu.css" type=text/css
rel=stylesheet <link>
<STYLE type=text/css>A:link {
COLOR: #000066; TEXT-DECORATION: none
}
A:visited {
COLOR: #000063; TEXT-DECORATION: none
}
A:hover {
COLOR: #ff0000; TEXT-DECORATION: underline
}
A:active {
TEXT-DECORATION: none
}
UL {
LIST-STYLE-TYPE: none
}
LI {
LIST-STYLE-TYPE: none
}
BODY {
FONT-SIZE: 14px; COLOR: #444444; FONT-FAMILY: 宋体
}
TD {
FONT-SIZE: 14px; COLOR: #444444; FONT-FAMILY: 宋体
}
TH {
FONT-SIZE: 14px; COLOR: #444444; FONT-FAMILY: 宋体
}
.STYLE4 {
FONT-WEIGHT: bold; FONT-SIZE: 18px
}
.STYLE5 {
FONT-SIZE: 22px
}
A {
FONT-SIZE: 12px
}
</STYLE>
<META content="MSHTML 6.00.2900.3268" name=GENERATOR></HEAD>
<BODY>
<SCRIPT language=JavaScript type=text/JavaScript>
function chg_img(num1,num2)
{
eval("document.bt_"+num2+".src='../image/annu_"+num1+num2+".jpg'");
}
</SCRIPT>
<DIV style="MARGIN: auto; WIDTH: 975px; HEIGHT: 111px"><IFRAME border=0
name=new_date11 marginWidth=0 marginHeight=0
src="jakarta commons-dbcp --米鼠网.files/toBriefnessAction.htm" frameBorder=0
noResize width="100%" scrolling=no height=115 spacing="0"
vspale="0">
</IFRAME></DIV>
<DIV
style="MARGIN: 5px auto auto; WIDTH: 975px; LINE-HEIGHT: 30px; HEIGHT: 30px"
align=left>您现在的位置是:<A href="http://www.misuland.com/home.html">首页</A>-> <A
href="http://www.misuland.com/news/jishu.html">米鼠技术</A> ->jakarta
commons-dbcp </DIV>
<DIV style="MARGIN: 5px auto auto; WIDTH: 975px" align=center>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD
style="BORDER-RIGHT: #c7d4dc 1px solid; BORDER-TOP: #c7d4dc 1px solid; BORDER-LEFT: #c7d4dc 1px solid; BORDER-BOTTOM: #c7d4dc 1px solid"
vAlign=top width=672 bgColor=#fafafd>
<DIV class="STYLE4 STYLE5"
style="MARGIN-TOP: 15px; LINE-HEIGHT: 50px; HEIGHT: 50px"
align=center>jakarta commons-dbcp </DIV>
<DIV align=center><SPAN><IFRAME border=0 name=new_date11 marginWidth=0
marginHeight=0 src="jakarta commons-dbcp --米鼠网.files/viewnumAction.htm"
frameBorder=0 noResize width=600 scrolling=no height=16 spacing="0"
vspale="0">
</IFRAME></SPAN></DIV>
<TABLE style="MARGIN-TOP: 25px; LINE-HEIGHT: 22px" cellSpacing=0
cellPadding=0 width="95%" align=center border=0>
<TBODY>
<TR>
<TD align=left height=27>
<TABLE cellSpacing=5 cellPadding=2 align=left border=0>
<TBODY>
<TR>
<TD height=20><!---LREC 20041231--->
<TABLE cellSpacing=0 cellPadding=0 width=60 border=0>
<TBODY>
<TR>
<TD
style="BORDER-RIGHT: #cccccc 1px solid; BORDER-TOP: #cccccc 1px solid; BORDER-LEFT: #cccccc 1px solid"
vAlign=center align=middle height=60>
<SCRIPT type=text/javascript>
<!--
var focus_width=280
var focus_height=220
var text_height=0
var swf_height = focus_height+text_height
var pics='../bbsimage/xinwen.jpg|../bbsimage/xinwen2.jpg|../bbsimage/3.jpg'
var links='../project/projectFactoryIndexAction.do|../findMSCAction.do|../project/projectFactoryIndexAction.do'
var texts=' '
document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+ focus_width +'" height="'+ swf_height +'">');
document.write('<param name="allowScriptAccess" value="sameDomain"><param name="movie" value="../picture/playswf.swf"><param name=wmode value=transparent><param name="quality" value="high">');
document.write('<param name="menu" value="false"><param name=wmode value="opaque">');
document.write('<param name="FlashVars" value="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'">');
document.write('<embed src="../picture/playswf.swf" wmode="opaque" FlashVars="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'" menu="false" bgcolor="#DADADA" quality="high" width="'+ focus_width +'" height="'+ swf_height +'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'); document.write('</object>');
//-->
</SCRIPT>
</TD></TR></TBODY></TABLE>
<SCRIPT language=JavaScript type=text/javascript>
var lrec_target="_top";
var lrec_URL = new Array();
lrec_URL[1] = "http://cn.rd.yahoo.com/SIG=12fb1snp5/M=554606.9682334.10396996.4396853/D=cn_ent/S=96490583:LREC/Y=CN/EXP=1165035329/A=4164078/R=0/*http://cnt.zhaopin.com/Market/whole_counter.jsp?sid=121111264&site=yahooCPM&url=http://www.zhaopin.com";
var lrec_link1 = "javascript:LRECopenWindow(1)";
var lrec_flashfile='http://cn.yimg.com/a/ad/daphne/554606_lrec_30nov06.swf?clickTAG='+lrec_link1+'';
var lrec_altURL="/D=cn_ent/S=96490583:LREC/Y=CN/EXP=1165035329/A=4164078/R=1/id=altimgurl/*http://cnt.zhaopin.com/Market/whole_counter.jsp?sid=121111264&site=yahooCPM&url=http://www.zhaopin.com";
var lrec_altimg="http://cn.yimg.com/a/cn/ethan/300x250.gif";
var lrec_width=300;
var lrec_height=250;
</SCRIPT>
<NOSCRIPT></NOSCRIPT><!---/LREC 20041231---></TD></TR></TBODY></TABLE><SPAN
class="font line-height">
<P style="TEXT-INDENT: 2em"><FONT size=2></FONT>
<P style="TEXT-INDENT: 2em"><FONT size=2>jakarta commons-dbcp
</FONT>
<P style="TEXT-INDENT: 2em"><BR><FONT size=2>1.DBCP简介 </FONT>
<P style="TEXT-INDENT: 2em"><BR><FONT
size=2>网络程序的设计,很多都涉及到和关系型数据库的交互操作,一般的操作方式都是使用的时候创建到数据库的连 </FONT>
<P style="TEXT-INDENT: 2em"><BR><FONT
size=2>接,然后进行各种操作,这种简单的操作方式带来的问题便是数据库的频繁的打开和关闭,以及Transtion的执 </FONT>
<P style="TEXT-INDENT: 2em"><BR><FONT
size=2>行,这是一种很耗费时间和资源的操作。于是数据库缓冲池DBCP就出现了,这个包是从pool包发展出来的。 </FONT>
<P style="TEXT-INDENT: 2em"><BR><FONT size=2>2.DBCP实现的基本流程 </FONT>
<P style="TEXT-INDENT: 2em"><BR><FONT size=2>1.创建enericObjectPool实例
</FONT>
<P style="TEXT-INDENT: 2em"><BR><FONT size=2>GenericObjectPool pool
= new GenericObjectPool(null); </FONT>
<P style="TEXT-INDENT: 2em"><BR><FONT
size=2>2.创建PoolableConnectionFactory </FONT>
<P style="TEXT-INDENT: 2em"><BR><FONT
size=2>DriverManagerConnectionFactory cf = </FONT>
<P style="TEXT-INDENT: 2em"><BR><FONT size=2>new
DriverManagerConnectionFactory( </FONT>
<P style="TEXT-INDENT: 2em"><BR><FONT size=2>"jdbc:mysql://host/db",
"username", "password"); </FONT>
<P