- 浏览: 43831 次
文章分类
- 全部博客 (29)
- java (29)
- ava框架数据库连接池比较(c3p0 (1)
- dbcp和proxool)bonecp (1)
- 并发编程的Java抽象 (1)
- Comparing PHP Frameworks ( Symfony (1)
- CakePHP (1)
- YII and CodeIgniter) (1)
- 简单的Unit Test理解 (1)
- mysql concat函数 字符串连接 (1)
- PHP学习笔记(一) (1)
- Struts2 工作流程 (1)
- 关于Java性能监控您不知道的5件事 (1)
- paypal注册难吗? (1)
- Android采用SharedPreferences保存用户登录信息 (1)
- 开微博 (1)
- 《疯狂的程序员》 (1)
- FindBugs无法使用的问题 (1)
- 将SVG文件嵌入到网页中的问题 并说object和embed标记 (1)
- 突然想说说IP地址欺骗 (1)
- 把.NET程序部署到没有安装.NET Framwork的机器上 (1)
- 写个小程序QQMessage 熟悉一下界面控件的使用 (1)
- 看流程图,写代码。 (1)
- ASP.NET MVC 2生成动态表单的一种最简单的思路 (1)
- 一网络能连接后提示用户的小程序 (1)
- 重载运算符之前++和后++ (1)
- Spring JMS 整合Tomcat和ActiveMQ (1)
- android Launch Mode and Flags (1)
- PPT打包成EXE常用方法 (1)
- Android开发之初识Camera图像采集 (1)
- Android开发之自定义动画 (1)
- Multiple operations have reported errors Select an error to view its details (1)
- Hadoop启动时出现Unrecognized option: -jvm 和 Could not create the Java virtual machine (1)
- pjhjava soap的开发 (1)
最新评论
-
wolf_awp:
受不了啊,这种东西都能到首页去。
看流程图,写代码。 -
depravedangel:
原帖:http://blog.csdn.net/arui319 ...
写个小程序QQMessage 熟悉一下界面控件的使用 -
depravedangel:
05年的帖子,直接拷贝过来,LZ不厚道
写个小程序QQMessage 熟悉一下界面控件的使用 -
depravedangel:
判断QQ是否隐身是怎么做的的?
写个小程序QQMessage 熟悉一下界面控件的使用
ava框架数据库连接池比较(c3p0,dbcp和proxool)bonecp
<h1 style="text-align: center; margin: 17pt 0cm 16.5pt;">[size=x-large;]<span style="" lang="EN-US"><span style="font-family: Times New Roman;">Java[/size]</span><span style="">框架数据库连接池比较(</span><span style="" lang="EN-US"><span style="font-family: Times New Roman;">c3p0,dbcp</span></span><span style="">和</span><span style="" lang="EN-US"><span style="font-family: Times New Roman;">proxool</span></span><span style="">)</span><span style="" lang="EN-US"></span></span></h1>
<table class="MsoNormalTable" style="width: 100%; border-collapse: collapse;" border="0" cellspacing="0" cellpadding="0" width="100%"><tbody><tr style="">
<td style="background-color: transparent; border: #d4d0c8; padding: 0.75pt;">
<h2 style="margin: 13pt 0cm;"><span style="" lang="EN-US">[size=large;]<span style="font-family: Arial;">1. Apache-DBCP [/size]</span></span></h2>
<p class="MsoNormal" style="text-align: left; margin: 0cm 0cm 0pt;" align="left"><span style="" lang="EN-US">? BasicDataSource </span><span style="">相关的参数说明<span lang="EN-US"> <br>dataSource: </span>要连接的<span lang="EN-US"> datasource (</span>通常我们不会定义在<span lang="EN-US"> server.xml) <br>defaultAutoCommit: </span>对于事务是否<span lang="EN-US"> autoCommit, </span>默认值为<span lang="EN-US"> true <br>defaultReadOnly: </span>对于数据库是否只能读取<span lang="EN-US">, </span>默认值为<span lang="EN-US"> false <br>driverClassName:</span>连接数据库所用的<span lang="EN-US"> JDBC Driver Class, <br>maxActive: </span>可以从对象池中取出的对象最大个数,为<span lang="EN-US">0</span>则表示没有限制,默认为<span lang="EN-US">8 <br>maxIdle: </span>最大等待连接中的数量<span lang="EN-US">,</span>设<span lang="EN-US"> 0 </span>为没有限制 (对象池中对象最大个数)<span lang="EN-US"> <br>minIdle</span>:对象池中对象最小个数<span lang="EN-US"> <br>maxWait: </span>最大等待秒数<span lang="EN-US">, </span>单位为<span lang="EN-US"> ms, </span>超过时间会丟出错误信息<span lang="EN-US"> <br>password: </span>登陆数据库所用的密码<span lang="EN-US"> <br>url: </span>连接数据库的<span lang="EN-US"> URL <br>username: </span>登陆数据库所用的帐号<span lang="EN-US"> <br>validationQuery: </span>验证连接是否成功<span lang="EN-US">, SQL SELECT </span>指令至少要返回一行<span lang="EN-US"> <br>removeAbandoned: </span>是否自我中断<span lang="EN-US">, </span>默认是<span lang="EN-US"> false <br>removeAbandonedTimeout: </span>几秒后会自我中断<span lang="EN-US">, removeAbandoned </span>必须为<span lang="EN-US"> true <br>logAbandoned: </span>是否记录中断事件<span lang="EN-US">, </span>默认为<span lang="EN-US"> false <br>minEvictableIdleTimeMillis</span>:大于<span lang="EN-US">0 </span>,进行连接空闲时间判断,或为<span lang="EN-US">0</span>,对空闲的连接不进行验证;默认<span lang="EN-US">30</span>分钟<span lang="EN-US"> <br>timeBetweenEvictionRunsMillis</span>:失效检查线程运行时间间隔,如果小于等于<span lang="EN-US">0</span>,不会启动检查线程,默认<span lang="EN-US">-1 <br>testOnBorrow</span>:取得对象时是否进行验证,检查对象是否有效,默认为<span lang="EN-US">false <br>testOnReturn</span>:返回对象时是否进行验证,检查对象是否有效,默认为<span lang="EN-US">false <br>testWhileIdle</span>:空闲时是否进行验证,检查对象是否有效,默认为<span lang="EN-US">false <br>? </span>在使用<span lang="EN-US">DBCP</span>的时候,如果使用默认值,则数据库连接因为某种原因断掉后,再从连接池中取得连接又不进行验证,这时取得的连接实际上就会是无效的数据库连接。因此为了防止获得的数据库连接失效,在使用的时候最好保证:<span lang="EN-US"> <br>username: </span>登陆数据库所用的帐号<span lang="EN-US"> <br>validationQuery</span>:<span lang="EN-US">SELECT COUNT(*) FROM DUAL <br>testOnBorrow</span>、<span lang="EN-US">testOnReturn</span>、<span lang="EN-US">testWhileIdle</span>:最好都设为<span lang="EN-US">true <br>minEvictableIdleTimeMillis</span>:大于<span lang="EN-US">0 </span>,进行连接空闲时间判断,或为<span lang="EN-US">0</span>,对空闲的连接不进行验证<span lang="EN-US"> <br>timeBetweenEvictionRunsMillis</span>:失效检查线程运行时间间隔,如果小于等于<span lang="EN-US">0</span>,不会启动检查线程<span lang="EN-US"> <br>? PS:</span>在构造<span lang="EN-US">GenericObjectPool [BasicDataSource</span>在其<span lang="EN-US">createDataSource () </span>方法中也会使用<span lang="EN-US">GenericObjectPool] </span>时,会生成一个内嵌类<span lang="EN-US">Evictor</span>,实现自<span lang="EN-US">Runnable</span>接口。如果<span lang="EN-US">timeBetweenEvictionRunsMillis</span>大于<span lang="EN-US">0</span>,每过<span lang="EN-US">timeBetweenEvictionRunsMillis</span>毫秒<span lang="EN-US">Evictor</span>会调用<span lang="EN-US">evict()</span>方法,检查对象的闲置时间是否大于<span lang="EN-US"> minEvictableIdleTimeMillis</span>毫秒(<span lang="EN-US">_minEvictableIdleTimeMillis</span>小于等于<span lang="EN-US">0</span>时则忽略,默认为<span lang="EN-US">30</span>分钟),是则销毁此对象,否则就激活并校验对象,然后调用<span lang="EN-US">ensureMinIdle</span>方法检查确保池中对象个数不小于<span lang="EN-US">_minIdle</span>。在调用<span lang="EN-US">returnObject</span>方法把对象放回对象池,首先检查该对象是否有效,然后调用<span lang="EN-US">PoolableObjectFactory </span>的<span lang="EN-US">passivateObject</span>方法使对象处于非活动状态。再检查对象池中对象个数是否小于<span lang="EN-US">maxIdle</span>,是则可以把此对象放回对象池,否则销毁此对象<span lang="EN-US"> <br>? </span>上述特性的可设置性已在代码中验证,具体性能是否能实现有待实际验证 <span lang="EN-US"></span></span>
<p class="MsoNormal" style="text-align: left; line-height: 10.95pt; margin: 0cm 0cm 0pt; background: white;" align="left">[size=x-small;]<span style="" lang="EN-US">?<Resource name="lda/raw"<br>????????????? type="javax.sql.DataSource"<br>?????????????? password="lda_master"<br>?????????????? driverClassName="oracle.jdbc.driver.OracleDriver"<br>?????????????? maxIdle="30" minIdle="2" maxWait="60000" maxActive="1000"[/size]<span style="" lang="EN-US">?</span></span><span style="" lang="EN-US"><br>[size=x-small;]?????????????? testOnBorrow="true" testWhileIdle="true" validationQuery="select 1 from dual"<br>?????????????? username="lda_master" url="jdbc:oracle:thin:@192.160.100.107:15537:lcststd"/>[/size]</span>
<p class="MsoNormal" style="text-align: left; line-height: 10.95pt; margin: 0cm 0cm 0pt; background: white;" align="left">[size=x-small;]<span style="">这样一来,就能够解决[/size]<span style="" lang="EN-US">Connect Reset</span><span style="">的问题了。刚才说了,其实很多</span><span style="" lang="EN-US">App Server</span><span style="">都会有相应的配置地方,只是大型的服务器正好提供了</span><span style="" lang="EN-US">Admin Console</span><span style="">,上面可以显式的配置</span><span style="" lang="EN-US">Connection Pool</span><span style="">,也有明显的属性选择,这里就不一一详述了,都是眼见的功夫。</span><span style="" lang="EN-US"></span></span>
<p class="MsoNormal" style="text-align: left; margin: 0cm 0cm 0pt;" align="left"><span style="" lang="EN-US">?</span>
<h2 style="margin: 13pt 0cm;"><span style="" lang="EN-US">[size=large;]<span style="font-family: Arial;">3. Proxool [/size]</span></span></h2>
<p class="MsoNormal" style="text-align: left; margin: 0cm 0cm 0pt;" align="left"><span style="" lang="EN-US">?</span>
</td>
</tr></tbody></table>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span lang="EN-US"><span style="font-family: Times New Roman; font-size: small;">?</span></span>
<h1 style="text-align: center; margin: 17pt 0cm 16.5pt;">[size=x-large;]<span style="">总结[/size]<span lang="EN-US"><span style="font-family: Times New Roman;">spring</span></span><span style="">下配置</span><span lang="EN-US"><span style="font-family: Times New Roman;">dbcp,c3p0,proxool</span></span><span style="">数据源链接池</span></span></h1>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span lang="EN-US"><span style="font-family: Times New Roman; font-size: small;">?</span></span>
<p class="MsoNormal" style="line-height: 17.25pt; margin: 0cm 0cm 0pt; background: white;"><span style=""><span style="color: #666666; font-size: 10pt;" lang="EN-US"><span style="font-family: Times New Roman;"><?xml version="1.0" encoding="UTF-8"?></span></span></span>
<p class="MsoNormal" style="line-height: 17.25pt; margin: 0cm 0cm 0pt; background: white;"><span style=""><span style="color: #666666; font-size: 10pt;" lang="EN-US"><span style="font-family: Times New Roman;"><beans default-autowire="no" default-lazy-init="true"<br>default-dependency-check="none"><br><description>datasource</description><br><!-- ???<br><bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"><br>?? <property name="driverClassName"><value>${jdbc.driverClassName}</value></property><br>?? <property name="url"><value>${jdbc.url}</value></property><br>?? <property name="username"><value>${jdbc.username}</value></property><br>?? <property name="password"><value>${jdbc.password}</value></property><br></bean><br>--></span></span></span>
<p class="MsoNormal" style="line-height: 17.25pt; margin: 0cm 0cm 0pt; background: white;"><span style=""><span style="color: #666666; font-size: 10pt;" lang="EN-US"><span style="font-family: Times New Roman;"><!--bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"><br>??????? <property name="driverClass"><value>${jdbc.driverClassName}</value></property><br>??????? <property name="jdbcUrl"><value>${jdbc.url}</value></property><br>??????? <property name="user"><value>${jdbc.username}</value></property><br>??????? <property name="password"><value>${jdbc.password}</value></property>??<br>??????? <property name="acquireIncrement"><value>5</value></property><br>??????? <property name="idleConnectionTestPeriod"><value>3000</value></property><br>??????? <property name="checkoutTimeout"><value>3000</value></property><br>??????? <property name="maxPoolSize"><value>80</value></property><br>??????? <property name="minPoolSize"><value>1</value></property><br>??????? <property name="maxStatements"><value>6000</value></property><br>??????? <property name="initialPoolSize"><value>5</value></property><br></bean--><br><br><!--<br>ComboPooledDataSource </span></span></span><span style=""><span style="">参数说明</span></span>
<p class="MsoNormal" style="line-height: 17.25pt; margin: 0cm 0cm 0pt; background: white;"><span style=""><span style="color: #666666; font-size: 10pt;" lang="EN-US"><span style="font-family: Times New Roman;"><!--bean id="dataSource" class="org.logicalcobwebs.proxool.ProxoolDataSource"><br>?? <property name="driver"><value>${jdbc.driverClassName}</value></property><br>?? <property name="driverUrl"><value>${jdbc.url}</value></property><br>?? <property name="user"><value>${jdbc.username}</value></property><br>?? <property name="password"><value>${jdbc.password}</value></property><br>?? <property name="alias"><value>test</value></property><br>?? <property name="houseKeepingSleepTime"><value>90000</value></property><br>?? <property name="prototypeCount"><value>10</value></property><br>?? <property name="maximumConnectionCount"><value>100</value></property><br>?? <property name="minimumConnectionCount"><value>10</value></property><br>?? <property name="trace"><value>true</value></property><br>?? <property name="verbose"><value>true</value></property><br></bean><br>--></span></span></span>
<p class="MsoNormal" style="line-height: 17.25pt; margin: 0cm 0cm 0pt; background: white;"><span style=""><span style="color: #666666; font-size: 10pt;" lang="EN-US"><span style="font-family: Times New Roman;">jdbc.properties</span></span></span>
<p class="MsoNormal" style="line-height: 17.25pt; margin: 0cm 0cm 0pt; background: white;"><span style=""><span style="color: #666666; font-size: 10pt;" lang="EN-US"><br><span style="font-family: Times New Roman;">#jdbc.driverClassName=org.hsqldb.jdbcDriver<br>#jdbc.url=jdbc:hsqldb:file:hsqldb/test<br>#jdbc.username=sa<br>#jdbc.password=</span></span></span>
<p class="MsoNormal" style="line-height: 17.25pt; margin: 0cm 0cm 0pt; background: white;"><span style=""><span style="color: #666666; font-size: 10pt;" lang="EN-US"><span style="font-family: Times New Roman;">#jdbc.url=jdbc:mysql://localhost:3306/test?user=root&amp;password=root&amp;useUnicode=true&amp;characterEncoding=UTF-8&amp;characterSetResults=UTF-8</span></span></span>
<p class="MsoNormal" style="line-height: 17.25pt; margin: 0cm 0cm 0pt; background: white;"><span style=""><span style="color: #666666; font-size: 10pt;" lang="EN-US"><span style="font-family: Times New Roman;">#jndi<br>jndi.factory.initial=weblogic.jndi.WLInitialContextFactory<br>jndi.provider.url=t3://127.0.0.1:7001<br>jndi.jndiName=jdbc/test</span></span></span>
<p class="MsoNormal" style="line-height: 16.75pt; margin: 0cm 0cm 0pt;"><span style=""><span style="color: #666666; font-size: 10pt;" lang="EN-US"><br><span style="font-family: Times New Roman;">#hibernate.dialect=org.hibernate.dialect.SQLServerDialect<br>hibernate.dialect=org.hibernate.dialect.MySQLInnoDBDialect<br>#hibernate.dialect=org.hibernate.dialect.HSQLDialect<br>hibernate.cache.use_query_cache=true<br>#hibernate.cache.provider_class=net.sf.hibernate.cache.EhCacheProvider<br>hibernate.cache.provider_class=org.hibernate.cache.EhCacheProvider<br>hibernate.show_sql=true<br>hibernate.format_sql=false<br>hibernate.transaction.auto_close_session=true<br>hibernate.connection.autocommit=false<br>hibernate.connection.isolation=2<br>hibernate.hbm2ddl.auto=update<br>hibernate.jdbc.fetch_size=50<br>hibernate.jdbc.batch_size=25<br>hibernate.default_batch_fetch_size=16<br>hibernate.transaction.factory_class=org.hibernate.transaction.JDBCTransactionFactory<br>#hibernate.transaction.factory_class=net.sf.hibernate.transaction.JDBCTransactionFactory<br>hibernate.query.factory_class=org.hibernate.hql.classic.ClassicQueryTranslatorFactory<br>hibernate.connection.release_mode=after_transaction<br>hibernate.cache.region_prefix=hibernate.cache.test<br>hibernate.default_schema=test</span></span></span><span style="color: #666666;" lang="EN-US"></span>
<h1 style="text-align: center; margin: 17pt 0cm 16.5pt;">[size=x-large;]<span lang="EN-US"><span style="font-family: Times New Roman;">tomcat[/size]</span><span style="">下配置数据库连接池</span><span lang="EN-US"><span style="font-family: Times New Roman;">DBCP</span></span><span style="">、</span><span lang="EN-US"><span style="font-family: Times New Roman;">C3P0</span></span><span style="">、</span><span lang="EN-US"><span style="font-family: Times New Roman;">Proxool</span></span></span></h1>
<h2 style="margin: 13pt 0cm;">[size=large;]<span lang="EN-US"><span style="font-family: Arial;">1[/size]</span><span style="">、将连接池的</span><span lang="EN-US"><span style="font-family: Arial;">jar</span></span><span style="">文件拷贝到</span><span lang="EN-US"><span style="font-family: Arial;">tomcat</span></span><span style="">的</span><span lang="EN-US"><span style="font-family: Arial;">lib</span></span><span style="">目录下</span></span></h2>
<span lang="EN-US"><span style="">(1)dbcp:</span></span>
[size=small;]<span style=""><span lang="EN-US">tomcat[/size]默认包含<span lang="EN-US">tomcat-dbcp.jar,</span>如果使用<span lang="EN-US">tomcat</span>自带的<span lang="EN-US">dbcp</span>则不用拷贝<span lang="EN-US">jar</span>文件。</span></span>
<span style="">如果要使用<span lang="EN-US">commons-dbcp</span>连接池,则要将<span lang="EN-US">commons-dbcp-xxx.jar</span>和<span lang="EN-US">commons-pool.jar</span>拷贝到<span lang="EN-US">tomcat</span>的<span lang="EN-US">lib</span>目录下。</span>
<span style="">(<span lang="EN-US">2</span>)<span lang="EN-US">c3p0</span>:</span>
<span style="">拷贝<span lang="EN-US">c3p0-xx.jar</span>到<span lang="EN-US">tomcat</span>的<span lang="EN-US">lib</span>目录下</span>
<span style="">(<span lang="EN-US">3</span>)<span lang="EN-US">proxool</span>:</span>
<span style="">拷贝<span lang="EN-US">proxool-xx.jar</span>、<span lang="EN-US">proxool-cglib.jar</span>、<span lang="EN-US">commons-logging-xxx.jar</span>到<span lang="EN-US">tomcat</span>的<span lang="EN-US">lib</span>目录下</span>
<h2 style="margin: 13pt 0cm;">[size=large;]<span lang="EN-US"><span style="font-family: Arial;">2[/size]</span><span style="">、打开</span><span lang="EN-US"><span style="font-family: Arial;">tomcat</span></span><span style="">的</span><span lang="EN-US"><span style="font-family: Arial;">context.xml</span></span><span style="">,进行如下配置:</span></span></h2>
[size=small;]<span style=""><span lang="EN-US"><!--dbcp--><br><Resource <br>??? name="jdbc/mysqlds-dbcp" <br>??? auth="Container" <br>??? type= "javax.sql.DataSource" <br>factory="org.apache.commons.dbcp.BasicDataSourceFactory"<!--[/size]这里使用的<span lang="EN-US">commons-dbcp</span>连接池<span lang="EN-US">--></span></span></span>
[size=small;]<span style=""><span lang="EN-US"><!--tomcat[/size]的<span lang="EN-US">dbcp</span>对应的<span lang="EN-US">factory</span>为:将<span lang="EN-US">commons</span>替换为<span lang="EN-US">tomcat</span>,也可不用配置</span></span><span lang="EN-US"><span style="">--><br>??? driverClassName="com.mysql.jdbc.Driver" <br>??? url="jdbc:mysql://localhost:3306/test"<br>??? username="root" <br>??? password=""<br>??? maxActive="100" <br>??? maxIdle="30"<br>??? maxWait="10000" > <br></Resource> <br>?? <!--c3p0--><br><Resource auth="Container"<br>???? description="DB Connection"<br>???? driverClass="com.mysql.jdbc.Driver"<br>???? maxPoolSize="100"<br>???? minPoolSize="2"<br>???? acquireIncrement="2"<br>???? name="jdbc/mysqlds-c3p0"<br>???? user="root"<br>???? password=""<br>???? factory="org.apache.naming.factory.BeanFactory"<br>???? type="com.mchange.v2.c3p0.ComboPooledDataSource"<br>???? jdbcUrl="jdbc:mysql://localhost:3306/test" /></span></span>
<span lang="EN-US"><span style=""><!--proxool--></span></span>
<span lang="EN-US"><span style=""><Resource name="jdbc/mysqlds-proxool" <br>???? auth="Container"?????? <br>???? type="javax.sql.DataSource" <br>???? factory="org.logicalcobwebs.proxool.ProxoolDataSource"?????? <br>???? proxool.alias="test"?????? <br>???? user="root"???? <br>???? password=""?????? <br>???? delegateProperties="foo=1,bar=true" <br>???? proxool.jndi-name="mysqljndi"????? <br>???? proxool.driver-url="jdbc:mysql://127.0.0.1:3306/test"?????? <br>???? proxool.driver-class="com.mysql.jdbc.Driver"???? <br>???? proxool.house-keeping-sleep-time="900000"???? <br>???? proxool.maximum-active-time="5" <br>???? proxool.prototype-count="3" <br>???? proxool.statistics="1m,15m,1d" <br>???? proxool.simultaneous-build-throttle="10" <br>???? proxool.minimum-connection-count="5" <br>???? proxool.maximum-connection-count="15"??? <br>/>??</span></span>
<h2 style="margin: 13pt 0cm;">[size=large;]<span lang="EN-US"><span style="font-family: Arial;">3[/size]</span><span style="">、在</span><span lang="EN-US"><span style="font-family: Arial;">web.xml</span></span><span style="">中配置如下代码:</span></span></h2>
[size=small;]<span style=""><span lang="EN-US"><resource-ref>?? <br><res-ref-name>jdbc/mysqlds-proxool</res-ref-name>?? <!--[/size]与<span lang="EN-US">context.xml</span>下的<span lang="EN-US">Resources</span>的<span lang="EN-US">name</span>属性一致</span></span><span lang="EN-US"><span style="">--><br><res-type>javax.sql.DataSource</res-type>?? <br><res-auth>Container</res-auth>?? <br></resource-ref></span></span>
<h2 style="margin: 13pt 0cm;">[size=large;]<span lang="EN-US"><span style="font-family: Arial;">4[/size]</span><span style="">、获取连接</span><span lang="EN-US"><span style="font-family: Arial;">java</span></span><span style="">代码:</span></span></h2>
[size=small;]<span style=""><span lang="EN-US">?? Context context = new InitialContext();<br>??? ds = (DataSource) context.lookup("java:/comp/env/jdbc/mysqlds-proxool");//[/size]与<span lang="EN-US">context.xml</span>下的<span lang="EN-US">Resources</span>的<span lang="EN-US">name</span>属性一致</span></span>
<h2 style="margin: 13pt 0cm;">[size=large;]<span lang="EN-US"><span style="font-family: Arial;">5[/size]</span><span style="">、常见问题:</span></span></h2>
<span style="">[size=small;]<span lang="EN-US">????? [/size](<span lang="EN-US">1</span>)<span lang="EN-US">create a new connection but it fail its test:</span></span></span>
<span style="">[size=small;]<span lang="EN-US">?????? [/size]在配置<span lang="EN-US">proxool</span>连接池时,可能会包以上错误,可以看看你的<span lang="EN-US">context.xml</span>配置<span lang="EN-US">,</span>将</span></span>
<p class="MsoNormal" style="line-height: 16.75pt; margin: 0cm 0cm 0pt;">[size=small;]<span lang="EN-US"><span style="font-family: Times New Roman;">proxool.test-before-use="true"[/size]</span><span style="">该行去掉即可,即在使用前不要进行测试</span><span style="color: #666666;" lang="EN-US"></span></span>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span lang="EN-US"><span style="font-family: Times New Roman; font-size: small;">?</span></span>
<h1 style="text-align: center; margin: 17pt 0cm 16.5pt;">
<span style="line-height: 240%; font-size: 18pt;" lang="EN-US"><span style="font-family: Times New Roman;">DBCP</span></span><span style="">,</span><span style="line-height: 240%; font-size: 18pt;" lang="EN-US"><span style="font-family: Times New Roman;">C3P0</span></span><span style="">,</span><span style="line-height: 240%; font-size: 18pt;" lang="EN-US"><span style="font-family: Times New Roman;">Proxool</span></span><span style="">,</span><span style="line-height: 240%; font-size: 18pt;" lang="EN-US"><span style="font-family: Times New Roman;">BoneCP</span></span><span style="">参数介绍</span><span style="font-family: Times New Roman; font-size: x-large;"> </span>
</h1>
<h2 style="margin: 13pt 0cm;">[size=large;]<span lang="EN-US"><span style="font-family: Arial;">1 Apache-DBCP[/size]</span><span style="">:</span><span style="font-family: Arial;"> </span></span></h2>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt;">[size=small;]<span lang="EN-US"><span style="font-family: Times New Roman;">dataSource: [/size]</span><span style="">要连接的</span><span lang="EN-US"><span style="font-family: Times New Roman;"> datasource (</span></span><span style="">通常我们不会定义在</span></span>[size=small;]<span lang="EN-US"><span style="font-family: Times New Roman;"> server.xml) <br>defaultAutoCommit: [/size]</span><span style="">对于事务是否</span><span lang="EN-US"><span style="font-family: Times New Roman;"> autoCommit, </span></span><span style="">默认值为</span></span>[size=small;]<span lang="EN-US"><span style="font-family: Times New Roman;"> true <br>defaultReadOnly: [/size]</span><span style="">对于数据库是否只能读取</span><span lang="EN-US"><span style="font-family: Times New Roman;">, </span></span><span style="">默认值为</span></span>[size=small;]<span lang="EN-US"><span style="font-family: Times New Roman;"> false <br>driverClassName:[/size]</span><span style="">连接数据库所用的</span></span>[size=small;]<span lang="EN-US"><span style="font-family: Times New Roman;"> JDBC Driver Class, <br>maxActive: [/size]</span><span style="">可以从对象池中取出的对象最大个数,为</span><span lang="EN-US"><span style="font-family: Times New Roman;">0</span></span><span style="">则表示没有限制,默认为</span></span>[size=small;]<span lang="EN-US"><span style="font-family: Times New Roman;">8 <br>maxIdle: [/size]</span><span style="">最大等待连接中的数量</span><span lang="EN-US"><span style="font-family: Times New Roman;">,</span></span><span style="">设</span><span lang="EN-US"><span style="font-family: Times New Roman;"> 0 </span></span><span style="">为没有限制</span><span style="font-family: Times New Roman;"> </span><span style="">(对象池中对象最大个数)</span></span>[size=small;]<span lang="EN-US"><span style="font-family: Times New Roman;"> <br>minIdle[/size]</span><span style="">:对象池中对象最小个数</span></span>[size=small;]<span lang="EN-US"><span style="font-family: Times New Roman;"> <br>maxWait: [/size]</span><span style="">最大等待秒数</span><span lang="EN-US"><span style="font-family: Times New Roman;">, </span></span><span style="">单位为</span><span lang="EN-US"><span style="font-family: Times New Roman;"> ms, </span></span><span style="">超过时间会丟出错误信息</span></span>[size=small;]<span lang="EN-US"><span style="font-family: Times New Roman;"> <br>password: [/size]</span><span style="">登陆数据库所用的密码</span></span>[size=small;]<span lang="EN-US"><span style="font-family: Times New Roman;"> <br>url: [/size]</span><span style="">连接数据库的</span></span>[size=small;]<span lang="EN-US"><span style="font-family: Times New Roman;"> URL <br>username: [/size]</span><span style="">登陆数据库所用的帐号</span></span>[size=small;]<span lang="EN-US"><span style="font-family: Times New Roman;"> <br>validationQuery: [/size]</span><span style="">验证连接是否成功</span><span lang="EN-US"><span style="font-family: Times New Roman;">, SQL SELECT </span></span><span style="">指令至少要返回一行</span></span>[size=small;]<span lang="EN-US"><span style="font-family: Times New Roman;"> <br>removeAbandoned: [/size]</span><span style="">是否自我中断</span><span lang="EN-US"><span style="font-family: Times New Roman;">, </span></span><span style="">默认是</span></span>[size=small;]<span lang="EN-US"><span style="font-family: Times New Roman;"> false <br>removeAbandonedTimeout: [/size]</span><span style="">几秒后会自我中断</span><span lang="EN-US"><span style="font-family: Times New Roman;">, removeAbandoned </span></span><span style="">必须为</span></span>[size=small;]<span lang="EN-US"><span style="font-family: Times New Roman;"> true <br>logAbandoned: [/size]</span><span style="">是否记录中断事件</span><span lang="EN-US"><span style="font-family: Times New Roman;">, </span></span><span style="">默认为</span></span>[size=small;]<span lang="EN-US"><span style="font-family: Times New Roman;"> false <br>minEvictableIdleTimeMillis[/size]</span><span style="">:大于</span><span lang="EN-US"><span style="font-family: Times New Roman;">0 </span></span><span style="">,进行连接空闲时间判断,或为</span><span lang="EN-US"><span style="font-family: Times New Roman;">0</span></span><span style="">,对空闲的连接不进行验证;默认</span><span lang="EN-US"><span style="font-family: Times New Roman;">30</span></span><span style="">分钟</span></span>[size=small;]<span lang="EN-US"><span style="font-family: Times New Roman;"> <br>timeBetweenEvictionRunsMillis[/size]</span><span style="">:失效检查线程运行时间间隔,如果小于等于</span><span lang="EN-US"><span style="font-family: Times New Roman;">0</span></span><span style="">,不会启动检查线程,默认</span></span>[size=small;]<span lang="EN-US"><span style="font-family: Times New Roman;">-1 <br>testOnBorrow[/size]</span><span style="">:取得对象时是否进行验证,检查对象是否有效,默认为</span></span>[size=small;]<span lang="EN-US"><span style="font-family: Times New Roman;">false <br>testOnReturn[/size]</span><span style="">:返回对象时是否进行验证,检查对象是否有效,默认为</span></span>[size=small;]<span lang="EN-US"><span style="font-family: Times New Roman;">false <br>testWhileIdle[/size]</span><span style="">:空闲时是否进行验证,检查对象是否有效,默认为</span></span>[size=small;]<span lang="EN-US"><span style="font-family: Times New Roman;">false <br>initialSize[/size]</span><span style="">:初始化线程数</span><span style="font-family: Times New Roman;"> </span></span>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span lang="EN-US"><span style="font-family: Times New Roman; font-size: small;">?</span></span>
<h2 style="margin: 13pt 0cm;">[size=large;]<span style="font-family: Arial;"><span lang="EN-US">2 C[/size]<span lang="EN-US">3P0</span></span><span style="">:</span><span style="font-family: Arial;"> </span></span></h2>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span lang="EN-US"><span style="font-family: Times New Roman; font-size: small;">?</span></span>
<h2 style="margin: 13pt 0cm;">[size=large;]<span lang="EN-US"><span style="font-family: Arial;">3 Proxool[/size]</span><span style="">:</span></span></h2>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span lang="EN-US"><span style="font-family: Times New Roman; font-size: small;">?</span></span>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span lang="EN-US"><span style="font-family: Times New Roman; font-size: small;">?</span></span>
<h2 style="margin: 13pt 0cm;">[size=large;]<span lang="EN-US"><span style="font-family: Arial;">4 BoneCP[/size]</span><span style="">:</span><span style="font-family: Arial;"> </span></span></h2>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span lang="EN-US"><span style="font-family: Times New Roman; font-size: small;">?</span></span>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span lang="EN-US"><span style="font-family: Times New Roman; font-size: small;">?</span></span>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="" lang="EN-US"><property</span><span style="" lang="EN-US"> </span><span style="" lang="EN-US">name="driverClass"</span><span style="" lang="EN-US"> </span><span style="" lang="EN-US">value="com.mysql.jdbc.Driver"</span><span style="" lang="EN-US"> </span><span style="" lang="EN-US">/></span>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="" lang="EN-US"><property</span><span style="" lang="EN-US"> </span><span style="" lang="EN-US">name="username"</span><span style="" lang="EN-US"> </span><span style="" lang="EN-US">value="root"/></span>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="" lang="EN-US"><property</span><span style="" lang="EN-US"> </span><span style="" lang="EN-US">name="idleConnectionTestPeriod"</span><span style="" lang="EN-US"> </span><span style="" lang="EN-US">value="60"/></span>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="" lang="EN-US"><property</span><span style="" lang="EN-US"> </span><span style="" lang="EN-US">name="maxConnectionsPerPartition"</span><span style="" lang="EN-US"> </span><span style="" lang="EN-US">value="30"/></span><span style="" lang="EN-US"></span>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="" lang="EN-US"><property</span><span style="" lang="EN-US"> </span><span style="" lang="EN-US">name="partitionCount"</span><span style="" lang="EN-US"> </span><span style="" lang="EN-US">value="3"/></span>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="" lang="EN-US"><property</span><span style="" lang="EN-US"> </span><span style="" lang="EN-US">name="statementsCacheSize"</span><span style="" lang="EN-US"> </span><span style="" lang="EN-US">value="100"/></span>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="" lang="EN-US"></bean></span><span style="" lang="EN-US"></span>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span lang="EN-US"><span style="font-family: Times New Roman; font-size: small;">?</span></span>
<h1 style="text-align: center; margin: 17pt 0cm 16.5pt;">[size=x-large;]<span style="font-family: Times New Roman;"><span lang="EN-US">1 c[/size]<span lang="EN-US">3p0</span></span><span style="">、</span><span lang="EN-US"><span style="font-family: Times New Roman;">dbcp</span></span><span style="">、</span><span lang="EN-US"><span style="font-family: Times New Roman;">proxool</span></span><span style="">、</span><span lang="EN-US"><span style="font-family: Times New Roman;">BoneCP</span></span><span style="">比较</span></span></h1>
<h2 style="margin: 13pt 0cm;">[size=large;]<span lang="EN-US"><span style="font-family: Arial;">1.1 [/size]</span><span style="">测试环境</span><span lang="EN-US"><span style="font-family: Arial;">:</span></span></span></h2>
<h2 style="margin: 13pt 0cm;">[size=large;]<span lang="EN-US"><span style="font-family: Arial;">1.2 [/size]</span><span style="">测试条件:</span><span style="font-family: Arial;"> </span></span></h2>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt;">[size=small;]<span lang="EN-US"><span style="font-family: Times New Roman;">initialSize=30; <br>maxSize=200; <br>minSize=30; <br>[/size]</span><span style="">其余参数为默认值;</span><span style="font-family: Times New Roman;"> </span></span>
<h2 style="margin: 13pt 0cm;">[size=large;]<span lang="EN-US"><span style="font-family: Arial;">1.3 [/size]</span><span style="">测试代码:</span></span></h2>
<h2 style="margin: 13pt 0cm;">[size=large;]<span lang="EN-US"><span style="font-family: Arial;">4.4[/size]</span><span style="">测试结果分析:</span></span></h2>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt;">[size=small;]<span lang="EN-US"><span style="font-family: Times New Roman;">???????? BoneCP[/size]</span><span style="">一直保持性能最佳</span><span style="font-family: Times New Roman;"> </span></span>
<h2 style="margin: 13pt 0cm;">[size=large;]<span lang="EN-US"><span style="font-family: Arial;">4.5 [/size]</span><span style="">测试结论</span><span style="font-family: Arial;"> </span></span></h2>
发表评论
-
pjhjava soap的开发
2012-02-07 16:50 934soap 的开发其实是wsdl到java的一个开发过程 ... -
Hadoop启动时出现Unrecognized option: -jvm 和 Could not create the Java virtual machine
2012-02-07 13:34 5475http://javoft.net/2011/06/h ... -
Multiple operations have reported errors Select an error to view its details
2012-01-31 16:53 1751<div id="blog_content&q ... -
Android开发之自定义动画
2012-01-11 16:54 2538<h1>Android开发之自定义动画&l ... -
Android开发之初识Camera图像采集
2012-01-11 15:39 3968<h1>Android开发之初识Camer ... -
PPT打包成EXE常用方法
2011-12-28 13:18 954<span style="fon ... -
android Launch Mode and Flags
2011-12-28 11:44 752android:allowTaskReparen ... -
Spring JMS 整合Tomcat和ActiveMQ
2011-12-21 14:34 22821.Active MQ安装配置 1.1.下载并解压A ... -
重载运算符之前++和后++
2011-12-21 10:19 1178<span style="font-f ... -
一网络能连接后提示用户的小程序
2011-12-20 11:59 792国庆节放假期间整个小区断网4天,家里没办法上网,基本都 ... -
ASP.NET MVC 2生成动态表单的一种最简单的思路
2011-12-20 11:14 1019在BPM、OA等系统中,都会存在一个表单设计器。有些 ... -
看流程图,写代码。
2011-12-19 12:59 2298看流程图,写代码。<br><br&g ... -
写个小程序QQMessage 熟悉一下界面控件的使用
2011-12-15 16:14 1385首先,代表我个人祝所有看到此日志的朋友新年快乐!! ... -
把.NET程序部署到没有安装.NET Framwork的机器上
2011-12-15 13:04 892<div class="text1&q ... -
突然想说说IP地址欺骗
2011-12-15 12:04 712<font size="3" ... -
将SVG文件嵌入到网页中的问题 并说object和embed标记
2011-12-14 14:44 1422<p class="MsoNormal ... -
FindBugs无法使用的问题
2011-12-13 11:44 1688<p class="MsoNorma ... -
《疯狂的程序员》
2011-12-13 10:19 606《疯狂的程序员》 年前,去书店,发现了一本书,摆在推荐 ... -
开微博
2011-12-12 13:09 606这里毕竟是CSDN,一个国内领先的IT技术站点。我这里 ... -
Android采用SharedPreferences保存用户登录信息
2011-12-09 11:39 4121[size=small;]??? Androi ...
相关推荐
本文将详细介绍几个常见的Java数据库连接池实现:C3P0、Druid、JNDI、DBCP、Proxool以及BoneCP,并结合Spring+MyBatis+maven环境下的应用示例进行解析。 1. C3P0: C3P0是一个开源的JDBC连接池,它实现了数据源和...
在Spring3中配置数据源,包括DBCP,C3P0,Proxool,Bonecp主要的数据源,里面包含这些数据源的jar文件和依赖文件及配置文件。。 如Bonecp目前听说是最快的数据源,速度是传统的c3p0的25倍, bonecp.properties文件: ...
本文将详细介绍四个常见的Java数据连接池组件——C3PO、Proxool、DBCP和BoneCP的配置与用法。 首先,我们来看C3PO(Comprehensive3rdPartyPooling),这是一个基于Apache Commons DBCP的数据库连接池实现,具有更好...
本文将深入解析几种常用的数据库连接池——Apache DBCP、C3P0、Proxool、BoneCP的详细配置参数,帮助开发者更好地理解和应用这些技术。 ### Apache DBCP **dataSource**: 配置数据源,通常在应用服务器的配置文件...
10. **BoneCP**:快速且开源的连接池,比C3P0和DBCP快25倍,适合性能敏感的应用。 在配置Hibernate与连接池的整合时,需要注意以下几点: 1. **Apache DBCP**:在Hibernate 2中支持,但在Hibernate 3中不推荐,...
对于提供连接池的数据源来说,除了Apache的DBCP以外,还有C3P0、Proxool、BoneCP等。具体如表1所示。 表1 基于JAVA的带连接池的数据源组件 序号 数据源名称 依赖的JAR包 实现的功能 1 Apache DBCP dbcp.jar、pool....
Druid是目前最好的数据库连接池,在功能、性能、扩展性方面,都超过其他数据库连接池,包括DBCP、C3P0、BoneCP、Proxool、JBoss DataSource。Druid已经在阿里巴巴部署了超过600个应用,经过一年多生产环境大规模部署...
Druid是目前最好的数据库连接池,在功能、性能、扩展性方面,都超过其他数据库连接池,包括DBCP、C3P0、BoneCP、Proxool、JBoss DataSource。 Druid已经在阿里巴巴部署了超过600个应用,经过一年多生产环境大规模...
Druid是目前最好的数据库连接池,在功能、性能、扩展性方面,都超过其他数据库连接池,包括DBCP、C3P0、BoneCP、Proxool、JBoss DataSource。 Druid已经在阿里巴巴部署了超过600个应用,经过一年多生产环境大规模...
3. **资源管理**:为了减少资源浪费并支持分布式系统,建议使用能够有效管理连接的连接池,如C3P0和BoneCP。 总之,选择合适的数据库连接池对于提升应用性能至关重要。开发者应根据具体的应用场景和技术要求来做出...
Java数据库连接池是一种重要的资源管理技术,用于优化数据库应用程序的性能和效率。它通过复用已建立的数据库连接,避免了频繁创建和销毁连接带来的开销。以下是对压缩包文件中涉及的几个主要连接池组件的详细介绍:...
Druid首先是一个数据库连接池。Druid是目前最好的数据库连接池,在功能、性能、扩展性方面,都超过其他数据库连接池,包括DBCP、C3P0、BoneCP、Proxool、JBoss DataSource。
Druid是阿里巴巴的开源产品,目前最好的数据库连接池,在功能、性能、扩展性方面,都超过其他数据库连接池,包括DBCP、C3P0、BoneCP、Proxool、JBoss DataSource。
Druid首先是一个数据库连接池。Druid是目前最好的数据库连接池,在功能、性能、扩展性方面,都超过其他数据库连接池,包括DBCP、C3P0、BoneCP、Proxool、JBoss DataSource。
Druid是目前最好的数据库连接池,在功能、性能、扩展性方面,都超过其他数据库连接池,包括DBCP、C3P0、BoneCP、Proxool、JBoss DataSource。 Druid已经在阿里巴巴部署了超过600个应用,经过一年多生产环境大规模...
本文将详细介绍几种常用的数据源解决方案及其配置方法,包括JNDI方式创建`DataSource`、Apache提供的简单连接池创建数据源、C3P0方式创建数据源、Proxool方式创建数据源以及BoneCP方式创建数据源。 #### JNDI 方式...
不同的连接池(如c3p0、dbcp、Proxool等)在性能和稳定性方面有所不同。例如,BoneCP在性能方面表现出色,而DBCP则更稳定。 - **批量数据处理:** 针对大批量数据处理任务,建议直接使用JDBC,以获得更好的性能。 *...
Druid是目前最好的数据库连接池,在功能、性能、扩展性方面,都超过其他数据库连接池,包括DBCP、C3P0、BoneCP、Proxool、JBoss DataSource。 Druid已经在阿里巴巴部署了超过600个应用,经过多年多生产环境大规模...