﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-cyicecream-随笔分类-JAVA小结</title><link>http://www.blogjava.net/cyicecream/category/3396.html</link><description>气质源于知识</description><language>zh-cn</language><lastBuildDate>Fri, 06 May 2011 07:11:15 GMT</lastBuildDate><pubDate>Fri, 06 May 2011 07:11:15 GMT</pubDate><ttl>60</ttl><item><title>国外java开源网站聚合(转载)</title><link>http://www.blogjava.net/cyicecream/archive/2011/05/05/349603.html</link><dc:creator>ceaboat</dc:creator><author>ceaboat</author><pubDate>Thu, 05 May 2011 07:31:00 GMT</pubDate><guid>http://www.blogjava.net/cyicecream/archive/2011/05/05/349603.html</guid><wfw:comment>http://www.blogjava.net/cyicecream/comments/349603.html</wfw:comment><comments>http://www.blogjava.net/cyicecream/archive/2011/05/05/349603.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/cyicecream/comments/commentRss/349603.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/cyicecream/services/trackbacks/349603.html</trackback:ping><description><![CDATA[<p>sourceforge <a href="http://www.sourceforge.net/"><font color="#0000ff">http://www.sourceforge.net</font></a><br />
java.net <a href="http://www.java.net/"><font color="#0000ff">http://www.java.net</font></a></p>
<p><a href="http://www.eclipse.org/"><font color="#0000ff">www.eclipse.org</font></a></p>
<p><a href="http://www.opensource.org/"><font color="#810081">www.opensource.org</font></a></p>
<p>Lomboz <a href="http://www.objectlearn.com/index.jsp"><font color="#0000ff">http://www.objectlearn.com/index.jsp</font></a> (J2EE plugin for Eclipse)<br />
htmlArea <a href="http://sourceforge.net/projects/itools-htmlarea/"><font color="#0000ff">http://sourceforge.net/projects/itools-htmlarea/</font></a> (所见即所得的在线HTML编辑器)<br />
XmlBuddy <a href="http://www.xmlbuddy.com/"><font color="#0000ff">http://www.xmlbuddy.com/</font></a> (XML Editor plugin for Eclipse)<br />
JFreeChart <a href="http://www.jfree.org/"><font color="#0000ff">http://www.jfree.org/</font></a> (用于生成图表的项目)<br />
EclipseME <a href="http://eclipseme.sourceforge.net/"><font color="#0000ff">http://eclipseme.sourceforge.net/</font></a> (J2ME Developmnt Plugin for Eclipse)<br />
mvnForum <a href="http://sourceforge.net/projects/mvnforum/"><font color="#0000ff">http://sourceforge.net/projects/mvnforum/</font></a> (论坛)<br />
jChatBox <a href="http://www.javazoom.net/index.shtml"><font color="#0000ff">http://www.javazoom.net/index.shtml</font></a> (用servlet实现的WEB聊天引擎)<br />
POI <a href="http://jakarta.apache.org/poi/index.html"><font color="#0000ff">http://jakarta.apache.org/poi/index.html</font></a> (用于处理Excel,WORD等文档的项目)<br />
FileUpload <a href="http://jakarta.apache.org/commons/fileupload/"><font color="#0000ff">http://jakarta.apache.org/commons/fileupload/</font></a> (用于处理HTTP文件上传得项目)<br />
PDFBox <a href="http://sourceforge.net/projects/pdfbox/"><font color="#0000ff">http://sourceforge.net/projects/pdfbox/</font></a> (处理PDF文档的项目)<br />
Lucene <a href="http://jakarta.apache.org/lucene/index.html"><font color="#0000ff">http://jakarta.apache.org/lucene/index.html</font></a> (搜索引擎)<br />
Digester <a href="http://jakarta.apache.org/commons/digester/"><font color="#0000ff">http://jakarta.apache.org/commons/digester/</font></a> (处理XML信息的项目)<br />
DBCP <a href="http://jakarta.apache.org/commons/dbcp/"><font color="#0000ff">http://jakarta.apache.org/commons/dbcp/</font></a> (数据库连接池)<br />
AXIS <a href="http://ws.apache.org/axis/"><font color="#0000ff">http://ws.apache.org/axis/</font></a> (WebService 的实现框架)<br />
Jetspeed <a href="http://portals.apache.org/jetspeed-1/"><font color="#0000ff">http://portals.apache.org/jetspeed-1/</font></a> (Portal)<br />
HSQLDB <a href="http://sourceforge.net/projects/hsqldb/"><font color="#0000ff">http://sourceforge.net/projects/hsqldb/</font></a> (Im memory Database Engine)<br />
CEWOLF <a href="http://sourceforge.net/projects/cewolf/"><font color="#810081">http://sourceforge.net/projects/cewolf/</font></a> (一套标签库实现Web报表,使用的是jFreeChart引擎)<br />
Struts Menu <a href="http://sourceforge.net/projects/struts-menu/"><font color="#810081">http://sourceforge.net/projects/struts-menu/</font></a> (基于Struts的Web菜单项目)<br />
htmlparser <a href="http://sourceforge.net/projects/htmlparser/"><font color="#0000ff">http://sourceforge.net/projects/htmlparser/</font></a> (用于解析HTML信息的项目)<br />
Mondrian <a href="http://sourceforge.net/projects/mondrian/(Open"><font color="#0000ff">http://sourceforge.net/projects/mondrian/(Open</font></a> Source OLAP Database)<br />
ProGuard <a href="http://sourceforge.net/projects/proguard/(Java"><font color="#0000ff">http://sourceforge.net/projects/proguard/(Java</font></a>的混淆器)<br />
InfoGlue <a href="http://sourceforge.net/projects/infoglue/"><font color="#0000ff">http://sourceforge.net/projects/infoglue/</font></a> (J2EE 内容管理系统)<br />
JPivot <a href="http://sourceforge.net/projects/jpivot/"><font color="#0000ff">http://sourceforge.net/projects/jpivot/</font></a> (基于WEB的OLAP 展现)<br />
<a href="http://java-source.net/"><font color="#0000ff">http://java-source.net/</font></a></p>
<div class="cnt"><a href="http://www.javaalmanac.com/" target="_blank"><font color="#765f47">http://www.javaalmanac.com</font></a> - Java开发者年鉴一书的在线版本. 要想快速查到某种Java技巧的用法及示例代码, 这是一个不错的去处.<br />
<a href="http://www.onjava.com/" target="_blank"><font color="#810081">http://www.onjava.com</font></a> - O'Reilly的Java网站. 每周都有新文章.<br />
<a href="http://java.sun.com/" target="_blank"><font color="#765f47">http://java.sun.com</font></a> - 官方的Java开发者网站 - 每周都有新文章发表.<br />
<a href="http://www.developer.com/java" target="_blank"><font color="#765f47">http://www.developer.com/java</font></a> - 由Gamelan.com 维护的Java技术文章网站.<br />
<a href="http://www.java.net/" target="_blank"><font color="#765f47">http://www.java.net</font></a> - Sun公司维护的一个Java社区网站.<br />
<a href="http://www.builder.com/" target="_blank"><font color="#765f47">http://www.builder.com</font></a> - Cnet的Builder.com网站 - 所有的技术文章, 以Java为主.<br />
<a href="http://www.ibm.com/developerworks/java" target="_blank"><font color="#765f47">http://www.ibm.com/developerworks/java</font></a> - IBM的Developerworks技术网站; 这是其中的Java技术主页.<br />
<a href="http://www.javaworld.com/" target="_blank"><font color="#810081">http://www.javaworld.com</font></a> - 最早的一个Java站点. 每周更新Java技术文章.<br />
<a href="http://www.devx.com/java" target="_blank"><font color="#765f47">http://www.devx.com/java</font></a> - DevX维护的一个Java技术文章网站.<br />
<a href="http://www.fawcette.com/javapro" target="_blank"><font color="#765f47">http://www.fawcette.com/javapro</font></a> - JavaPro在线杂志网站.<br />
<a href="http://www.sys-con.com/java" target="_blank"><font color="#765f47">http://www.sys-con.com/java</font></a> - Java Developers Journal的在线杂志网站.<br />
<a href="http://www.javadesktop.org/" target="_blank"><font color="#765f47">http://www.javadesktop.org</font></a> - 位于Java.net的一个Java桌面技术社区网站.<br />
<a href="http://www.theserverside.com/" target="_blank"><font color="#765f47">http://www.theserverside.com</font></a> - 这是一个讨论所有Java服务器端技术的网站.<br />
<a href="http://www.jars.com/" target="_blank"><font color="#765f47">http://www.jars.com</font></a> - 提供Java评论服务. 包括各种framework和应用程序.<br />
<a href="http://www.jguru.com/" target="_blank"><font color="#765f47">http://www.jguru.com</font></a> - 一个非常棒的采用Q&amp;A形式的Java技术资源社区.<br />
<a href="http://www.javaranch.com/" target="_blank"><font color="#765f47">http://www.javaranch.com</font></a> - 一个论坛，得到Java问题答案的地方，初学者的好去处。<br />
<a href="http://www.ibiblio.org/javafaq/javafaq.html" target="_blank"><font color="#765f47">http://www.ibiblio.org/javafaq/javafaq.html</font></a> - comp.lang.java的FAQ站点 - 收集了来自comp.lang.java新闻组的问题和答案的分类目录.<br />
<a href="http://java.sun.com/docs/books/tutorial/" target="_blank"><font color="#765f47">http://java.sun.com/docs/books/tutorial/</font></a> - 来自SUN公司的官方Java指南 - 对于了解几乎所有的java技术特性非常有帮助.<br />
<a href="http://www.javablogs.com/" target="_blank"><font color="#765f47">http://www.javablogs.com</font></a> - 互联网上最活跃的一个Java Blog网站.<br />
<a href="http://java.about.com/" target="_blank"><font color="#765f47">http://java.about.com/</font></a> - 来自About.com的Java新闻和技术文章网站</div>
HttpClient <a href="http://jakarta.apache.org/commons/httpclient/"><font color="#0000ff">http://jakarta.apache.org/commons/httpclient/</font></a> 处理http客户端的接口<br />
<font color="#000099"><strong><br />
原文地址</strong></font> <a href="http://blog.csdn.net/Xviewee/archive/2007/12/17/1944374.aspx" target="_blank">http://blog.csdn.net/Xviewee/archive/2007/12/17/1944374.aspx</a> 
<img src ="http://www.blogjava.net/cyicecream/aggbug/349603.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/cyicecream/" target="_blank">ceaboat</a> 2011-05-05 15:31 <a href="http://www.blogjava.net/cyicecream/archive/2011/05/05/349603.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>WAS部署中遇到的问题</title><link>http://www.blogjava.net/cyicecream/archive/2006/01/25/29202.html</link><dc:creator>ceaboat</dc:creator><author>ceaboat</author><pubDate>Wed, 25 Jan 2006 07:09:00 GMT</pubDate><guid>http://www.blogjava.net/cyicecream/archive/2006/01/25/29202.html</guid><wfw:comment>http://www.blogjava.net/cyicecream/comments/29202.html</wfw:comment><comments>http://www.blogjava.net/cyicecream/archive/2006/01/25/29202.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/cyicecream/comments/commentRss/29202.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/cyicecream/services/trackbacks/29202.html</trackback:ping><description><![CDATA[<P><FONT size=1>现象一：<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;错误信息：<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT color=#800080 size=2>java.lang.SecurityException: sealing violation: can't seal package oracle.jdbc.driver: already loaded<BR></FONT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;原因：<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; was启动的lib里存在多个ORACLE DRIVER。<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;解决：<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 保留最新的一个驱动包解决。<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;遗留问题：<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 开发环境使用TOMCAT发布无此问题，JBUILDER2006开发中包是有优先顺序的，即使存在多个<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;相同的类，优先选择第一个找到的类。WAS在这方面显然存在不足，排异容错性不够强大。<BR>现象二：<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 错误信息：<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT size=3><FONT color=#800080 size=2>Error 500: LinkageError while defining class: com.gzedu.eecn.structure.login.action.UserLoginAction Could not be defined due to: com/gzedu/eecn/structure/login/action/UserLoginAction (Illegal constant pool type) This is often caused by having a class defined at multiple locations within the classloader hierarchy. Other potential causes include compiling against an older or newer version of the class that has an incompatible method signature. Dumping the current context classloader</FONT> <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT size=1> 原因：<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 上传的文件已经损坏。重复试过很多次，发现本机器通过SSH上传过程中文件已经损坏。<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;属于本机问题。<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 解决：<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;通过同事的机器上传文件解决<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;总结：<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;类似此问题出现的几率很小，可以认为是相同的环境，使用相同的方式做一件事情也有可能出现<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 不同的效果。再次出现类似问题可以更快的定位错误点。<BR>现象三：<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 错误信息：<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<FONT color=#800080 size=2>&nbsp;com.ibm.ws.jsp.translator.JspTranslationException: JSPG0227E: 转换 /login.jsp:&nbsp; <BR>/login.jsp(1,1) --&gt; JSPG0145E: 未知 JSP 元素：jsp:directive.pagelanguage<BR></FONT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;原因：<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;windows环境、tomcat作为服务器开发，部署到sit、unix环境，会出现页面不同的开发环境会<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;有中文问题，或是说重复定义encoding的问题页面编码问题。<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 解决：<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;按照如下进行修改和配置；<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT size=1>1. 对于不是被include的页面必须使用；<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;%@ page contentType="text/html;charset=GBK" pageEncoding="GBK" language="java" %&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;。 大写GBK<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2. 对于被Include的页面必须使用如下；<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 。&lt;%@ page pageEncoding="GBK" language="java" %&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;注：在TOMCAT4.1.30--&gt;was5.0,6.0出现此问题<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</FONT></P><img src ="http://www.blogjava.net/cyicecream/aggbug/29202.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/cyicecream/" target="_blank">ceaboat</a> 2006-01-25 15:09 <a href="http://www.blogjava.net/cyicecream/archive/2006/01/25/29202.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>关于CachedRowSet</title><link>http://www.blogjava.net/cyicecream/archive/2005/12/09/23075.html</link><dc:creator>ceaboat</dc:creator><author>ceaboat</author><pubDate>Fri, 09 Dec 2005 01:57:00 GMT</pubDate><guid>http://www.blogjava.net/cyicecream/archive/2005/12/09/23075.html</guid><wfw:comment>http://www.blogjava.net/cyicecream/comments/23075.html</wfw:comment><comments>http://www.blogjava.net/cyicecream/archive/2005/12/09/23075.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/cyicecream/comments/commentRss/23075.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/cyicecream/services/trackbacks/23075.html</trackback:ping><description><![CDATA[sun.jdbc.rowset.CachedRowSet是sun提供的缓存数据集的一个类（数据集持久化），对BLOG，CLOG不能支持，LOG的容量是4G，结果集里存在LOG字段缓存时会报java.lang.NumberFormatException: For input string: "4294967295"<BR>据说sun对LOG的支持原来是2G，不晓得是否有支持4G的类。<BR><BR>对于原来使用的com.sun.rowset.CachedRowSetImpl深感疑惑此类在缓存number字段的时候如果SCALE没声明会报不能小于0的异常<img src ="http://www.blogjava.net/cyicecream/aggbug/23075.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/cyicecream/" target="_blank">ceaboat</a> 2005-12-09 09:57 <a href="http://www.blogjava.net/cyicecream/archive/2005/12/09/23075.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>点点滴滴</title><link>http://www.blogjava.net/cyicecream/archive/2005/11/23/21131.html</link><dc:creator>ceaboat</dc:creator><author>ceaboat</author><pubDate>Wed, 23 Nov 2005 07:31:00 GMT</pubDate><guid>http://www.blogjava.net/cyicecream/archive/2005/11/23/21131.html</guid><wfw:comment>http://www.blogjava.net/cyicecream/comments/21131.html</wfw:comment><comments>http://www.blogjava.net/cyicecream/archive/2005/11/23/21131.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/cyicecream/comments/commentRss/21131.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/cyicecream/services/trackbacks/21131.html</trackback:ping><description><![CDATA[1.GB2312支持拼音排序，GBK、GB18030不支持。2005年11月23日15:31:42<BR>2.websphere5与6的区别：5对路径不需要/，而6必须要/，否则因为少了/找不到相应的配置文件<BR><img src ="http://www.blogjava.net/cyicecream/aggbug/21131.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/cyicecream/" target="_blank">ceaboat</a> 2005-11-23 15:31 <a href="http://www.blogjava.net/cyicecream/archive/2005/11/23/21131.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>多注意一些细节</title><link>http://www.blogjava.net/cyicecream/archive/2005/11/09/19038.html</link><dc:creator>ceaboat</dc:creator><author>ceaboat</author><pubDate>Wed, 09 Nov 2005 12:17:00 GMT</pubDate><guid>http://www.blogjava.net/cyicecream/archive/2005/11/09/19038.html</guid><wfw:comment>http://www.blogjava.net/cyicecream/comments/19038.html</wfw:comment><comments>http://www.blogjava.net/cyicecream/archive/2005/11/09/19038.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/cyicecream/comments/commentRss/19038.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/cyicecream/services/trackbacks/19038.html</trackback:ping><description><![CDATA[通过URL来访问网站，action里request.getMothod()得到的GET.<BR>而通过FORM来提交的则可以设置POST，可以通过这两种方<BR>式的差异来做一些第一次访问与之后访问的一些个性化设置。<img src ="http://www.blogjava.net/cyicecream/aggbug/19038.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/cyicecream/" target="_blank">ceaboat</a> 2005-11-09 20:17 <a href="http://www.blogjava.net/cyicecream/archive/2005/11/09/19038.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>CachedRowSet </title><link>http://www.blogjava.net/cyicecream/archive/2005/10/01/14582.html</link><dc:creator>ceaboat</dc:creator><author>ceaboat</author><pubDate>Sat, 01 Oct 2005 04:54:00 GMT</pubDate><guid>http://www.blogjava.net/cyicecream/archive/2005/10/01/14582.html</guid><wfw:comment>http://www.blogjava.net/cyicecream/comments/14582.html</wfw:comment><comments>http://www.blogjava.net/cyicecream/archive/2005/10/01/14582.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/cyicecream/comments/commentRss/14582.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/cyicecream/services/trackbacks/14582.html</trackback:ping><description><![CDATA[WASD支持热启动，修改代码保存服务器进行实时更新，CachedRowSet crs = new CachedRowSetImpl();缓存数据集出异常。服务器热启动与缓存机制之间有冲突。<img src ="http://www.blogjava.net/cyicecream/aggbug/14582.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/cyicecream/" target="_blank">ceaboat</a> 2005-10-01 12:54 <a href="http://www.blogjava.net/cyicecream/archive/2005/10/01/14582.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>影响性能的测试报告（数据库版）测试源代码</title><link>http://www.blogjava.net/cyicecream/archive/2005/09/26/14152.html</link><dc:creator>ceaboat</dc:creator><author>ceaboat</author><pubDate>Mon, 26 Sep 2005 14:36:00 GMT</pubDate><guid>http://www.blogjava.net/cyicecream/archive/2005/09/26/14152.html</guid><wfw:comment>http://www.blogjava.net/cyicecream/comments/14152.html</wfw:comment><comments>http://www.blogjava.net/cyicecream/archive/2005/09/26/14152.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/cyicecream/comments/commentRss/14152.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/cyicecream/services/trackbacks/14152.html</trackback:ping><description><![CDATA[<P>                                                        <A href="http://www.blogjava.net/cyicecream/cyicecream/cyicecream/archive/2005/09/25/14000.html">  </A><FONT color=#ffffff size=6><STRONG><A href="http://www.blogjava.net/cyicecream/cyicecream/cyicecream/archive/2005/09/25/14000.html"><FONT color=#000000 size=5>测试源代码</FONT><BR></A></STRONG></FONT><BR>CapabilityForConnection 主运行程序，读取配置文件init.properties、reference.properties初始化参数。调用<FONT color=#000000>POOLTEST（一次完整的测试用例），计算其平均时间与使用连接数</FONT> </P>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><SPAN style="COLOR: #0000ff"><FONT size=3>package</FONT></SPAN><FONT size=3><SPAN style="COLOR: #000000"> com.cea.repository.test;<BR><BR></SPAN><SPAN style="COLOR: #0000ff">import</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000"> org.apache.commons.logging.LogFactory;<BR></SPAN><SPAN style="COLOR: #0000ff">import</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000"> org.apache.commons.logging.Log;<BR></SPAN><SPAN style="COLOR: #0000ff">import</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000"> java.util.Properties;<BR></SPAN><SPAN style="COLOR: #0000ff">import</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000"> java.io.FileInputStream;<BR></SPAN><SPAN style="COLOR: #0000ff">import</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000"> java.io.InputStream;<BR><BR></SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">class</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000"> CapabilityForConnection {<BR>    </SPAN><SPAN style="COLOR: #0000ff">private</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000"> Log log </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> LogFactory.getLog(CapabilityForConnection.</SPAN><SPAN style="COLOR: #0000ff">class</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000">);<BR>    </SPAN><SPAN style="COLOR: #008000">/**</SPAN></FONT><SPAN style="COLOR: #008000"><BR><FONT size=3>     * 计算一次测试所消耗的时间<BR>     </FONT></SPAN><SPAN style="COLOR: #008000"><FONT size=3>*/</FONT></SPAN><SPAN style="COLOR: #000000"><BR><FONT size=3>    </FONT></SPAN><FONT size=3><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">long</SPAN><SPAN style="COLOR: #000000"> times </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">0</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000">;<BR>    </SPAN><SPAN style="COLOR: #008000">/**</SPAN></FONT><SPAN style="COLOR: #008000"><BR><FONT size=3>     * 连接数<BR>     </FONT></SPAN><SPAN style="COLOR: #008000"><FONT size=3>*/</FONT></SPAN><SPAN style="COLOR: #000000"><BR><FONT size=3>    </FONT></SPAN><FONT size=3><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">long</SPAN><SPAN style="COLOR: #000000"> psize </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">0</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000">;<BR><BR>    </SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000"> main(String[] args) </SPAN><SPAN style="COLOR: #0000ff">throws</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000"> Exception {<BR>        </SPAN><SPAN style="COLOR: #008000">/**</SPAN></FONT><SPAN style="COLOR: #008000"><BR><FONT size=3>         * 运行的次数<BR>         </FONT></SPAN><SPAN style="COLOR: #008000"><FONT size=3>*/</FONT></SPAN><SPAN style="COLOR: #000000"><BR><FONT size=3>        </FONT></SPAN><FONT size=3><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> size </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">1</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000">;<BR>        </SPAN><SPAN style="COLOR: #008000">/**</SPAN></FONT><SPAN style="COLOR: #008000"><BR><FONT size=3>         * 见POOLTEST说明<BR>         </FONT></SPAN><SPAN style="COLOR: #008000"><FONT size=3>*/</FONT></SPAN><SPAN style="COLOR: #000000"><BR><FONT size=3>        </FONT></SPAN><FONT size=3><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> execsum </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">0</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000">;<BR>        </SPAN><SPAN style="COLOR: #008000">/**</SPAN></FONT><SPAN style="COLOR: #008000"><BR><FONT size=3>         * 见POOLTEST说明<BR>         </FONT></SPAN><SPAN style="COLOR: #008000"><FONT size=3>*/</FONT></SPAN><SPAN style="COLOR: #000000"><BR><FONT size=3>        </FONT></SPAN><FONT size=3><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> opencon </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">0</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000">;<BR>        </SPAN><SPAN style="COLOR: #008000">/**</SPAN></FONT><SPAN style="COLOR: #008000"><BR><FONT size=3>         * execsum对应properties的命名<BR>         </FONT></SPAN><SPAN style="COLOR: #008000"><FONT size=3>*/</FONT></SPAN><SPAN style="COLOR: #000000"><BR><FONT size=3>        String execs </FONT></SPAN><FONT size=3><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">null</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000">;<BR>        </SPAN><SPAN style="COLOR: #008000">/**</SPAN></FONT><SPAN style="COLOR: #008000"><BR><FONT size=3>         * opencon对应properties的命名<BR>         </FONT></SPAN><SPAN style="COLOR: #008000"><FONT size=3>*/</FONT></SPAN><SPAN style="COLOR: #000000"><BR><FONT size=3>        String openc </FONT></SPAN><FONT size=3><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">null</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000">;<BR><BR>        </SPAN><SPAN style="COLOR: #0000ff">long</SPAN><SPAN style="COLOR: #000000"> sumtime </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">0</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000">;<BR>        Properties prop </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> initProperty(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">reference.properties</SPAN><SPAN style="COLOR: #000000">"</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000">);<BR>        Properties init </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> initProperty(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">init.properties</SPAN><SPAN style="COLOR: #000000">"</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000">);<BR><BR>        </SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000"> (init.size() </SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">0</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000">) {<BR>            Object o </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> init.get(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">init</SPAN><SPAN style="COLOR: #000000">"</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000">);<BR>            size </SPAN><SPAN style="COLOR: #000000">=</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000"> Integer.parseInt(o.toString());<BR>            execs </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> init.get(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">name0</SPAN><SPAN style="COLOR: #000000">"</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000">).toString();<BR>            openc </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> init.get(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">name1</SPAN><SPAN style="COLOR: #000000">"</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000">).toString();<BR>        }<BR><BR>        </SPAN><SPAN style="COLOR: #0000ff">for</SPAN><SPAN style="COLOR: #000000"> (</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> i </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">; i </SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #000000"> prop.size() </SPAN><SPAN style="COLOR: #000000">/</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">2</SPAN><SPAN style="COLOR: #000000">; i</SPAN><SPAN style="COLOR: #000000">++</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000">) {<BR>            execsum </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> Integer.parseInt(prop.getProperty(execs </SPAN><SPAN style="COLOR: #000000">+</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000"> i).toString());<BR>            opencon </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> Integer.parseInt(prop.getProperty(openc </SPAN><SPAN style="COLOR: #000000">+</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000"> i).toString());<BR>            sumtime </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">0</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000">;<BR>            psize </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">0</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000">;<BR>            log.info(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">第</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000"> (i </SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">1</SPAN><SPAN style="COLOR: #000000">) </SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">组数据:</SPAN><SPAN style="COLOR: #000000">"</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000">);<BR>            log.info(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">并发应用数：</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000"> execsum </SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000"> 模拟连接数：</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">+</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000"> opencon);<BR><BR>            String[] reference </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> {</SPAN><SPAN style="COLOR: #000000">""</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000"> execsum, </SPAN><SPAN style="COLOR: #000000">""</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">+</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000"> opencon};<BR>            </SPAN><SPAN style="COLOR: #0000ff">for</SPAN><SPAN style="COLOR: #000000"> (</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> j </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">; j </SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #000000"> size; j</SPAN><SPAN style="COLOR: #000000">++</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000">) {<BR>                times </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">0</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000">;<BR>                PoolTest.main(reference);<BR>                sumtime </SPAN><SPAN style="COLOR: #000000">+=</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000"> times;<BR>            }<BR>            log.info(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">第</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000"> (i </SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">1</SPAN><SPAN style="COLOR: #000000">) </SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">组数据共执行</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000"> size </SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">次;平均耗时为：</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">+</SPAN></FONT><SPAN style="COLOR: #000000"><BR><FONT size=3>                     sumtime </FONT></SPAN><FONT size=3><SPAN style="COLOR: #000000">/</SPAN><SPAN style="COLOR: #000000"> (size </SPAN><SPAN style="COLOR: #000000">*</SPAN><SPAN style="COLOR: #000000"> execsum) </SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">毫秒</SPAN><SPAN style="COLOR: #000000">"</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000">);<BR>            log.info(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">平均使用</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000"> psize </SPAN><SPAN style="COLOR: #000000">/</SPAN><SPAN style="COLOR: #000000"> size </SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">个连接</SPAN><SPAN style="COLOR: #000000">"</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000">);<BR><BR>        }<BR>    }<BR><BR>    </SPAN><SPAN style="COLOR: #0000ff">private</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000"> Properties initProperty(String filename) </SPAN><SPAN style="COLOR: #0000ff">throws</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000"> Exception {<BR>        InputStream is </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">new</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000"> FileInputStream(filename);<BR>        Properties prop </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">new</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000"> Properties();<BR>        prop.load(is);<BR>        </SPAN><SPAN style="COLOR: #0000ff">return</SPAN></FONT><SPAN style="COLOR: #000000"><FONT size=3> prop;<BR><BR>    }<BR>}<BR></FONT></SPAN></DIV><BR>POOLTEST计算一次完整过程耗时，统计消耗的连接<BR>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><SPAN style="COLOR: #0000ff"><FONT size=3><SPAN style="COLOR: #0000ff"><FONT size=3>package</FONT></SPAN><FONT size=3><SPAN style="COLOR: #000000"> com.cea.repository.test;</SPAN></FONT><BR><BR>import</FONT></SPAN><FONT size=3><SPAN style="COLOR: #000000"> com.cea.repository.test.testdata.MainExecute;<BR></SPAN><SPAN style="COLOR: #0000ff">import</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000"> java.util.HashMap;<BR></SPAN><SPAN style="COLOR: #0000ff">import</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000"> java.util.Map;<BR></SPAN><SPAN style="COLOR: #0000ff">import</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000"> com.cea.repository.connection.PoolSupper;<BR></SPAN><SPAN style="COLOR: #0000ff">import</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000"> org.apache.commons.logging.LogFactory;<BR></SPAN><SPAN style="COLOR: #0000ff">import</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000"> org.apache.commons.logging.Log;<BR></SPAN><SPAN style="COLOR: #008000">/**</SPAN></FONT><SPAN style="COLOR: #008000"><BR><FONT size=3> *<BR> * 
<P>Title: 连接池性能测试</P><BR> *<BR> * 
<P>Description: 测试不合理的利用连接对WEB应用所造成影响.</P><BR> *<BR> * 
<P>Copyright: Copyright (c) 2005</P><BR> *<BR> * 
<P>Company: </P><BR> *<BR> * </FONT></SPAN><SPAN style="COLOR: #808080"><FONT size=3>@author</FONT></SPAN><FONT size=3><SPAN style="COLOR: #008000"> 小舟<BR> * </SPAN><SPAN style="COLOR: #808080">@version</SPAN></FONT><FONT size=3><SPAN style="COLOR: #008000"> 1.0<BR> </SPAN><SPAN style="COLOR: #008000">*/</SPAN></FONT><SPAN style="COLOR: #000000"><BR></SPAN><FONT size=3><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000"> PoolTest </SPAN><SPAN style="COLOR: #0000ff">extends</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000"> Thread {<BR>    </SPAN><SPAN style="COLOR: #0000ff">private</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000"> Log log </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> LogFactory.getLog(PoolTest.</SPAN><SPAN style="COLOR: #0000ff">class</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000">);<BR>    </SPAN><SPAN style="COLOR: #008000">/**</SPAN></FONT><SPAN style="COLOR: #008000"><BR><FONT size=3>     * 并发执行MainExecute的数量<BR>     </FONT></SPAN><SPAN style="COLOR: #008000"><FONT size=3>*/</FONT></SPAN><SPAN style="COLOR: #000000"><BR><FONT size=3>    </FONT></SPAN><FONT size=3><SPAN style="COLOR: #0000ff">private</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> EXECUTESUM </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">35</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000">;<BR>    </SPAN><SPAN style="COLOR: #008000">/**</SPAN></FONT><SPAN style="COLOR: #008000"><BR><FONT size=3>     * 一次MainExecute执行所请求的连接数<BR>     </FONT></SPAN><SPAN style="COLOR: #008000"><FONT size=3>*/</FONT></SPAN><SPAN style="COLOR: #000000"><BR><FONT size=3>    </FONT></SPAN><FONT size=3><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> CONNECTIONS </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">3</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000">;<BR>    </SPAN><SPAN style="COLOR: #008000">/**</SPAN></FONT><SPAN style="COLOR: #008000"><BR><FONT size=3>     * 记录所使用的连接<BR>     </FONT></SPAN><SPAN style="COLOR: #008000"><FONT size=3>*/</FONT></SPAN><SPAN style="COLOR: #000000"><BR><FONT size=3>    </FONT></SPAN><FONT size=3><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000"> Map poolTestMap </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">new</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000"> HashMap();<BR>    </SPAN><SPAN style="COLOR: #008000">/**</SPAN></FONT><SPAN style="COLOR: #008000"><BR><FONT size=3>     * 第sum次执行MainExecute所需要的时间<BR>     </FONT></SPAN><SPAN style="COLOR: #008000"><FONT size=3>*/</FONT></SPAN><SPAN style="COLOR: #000000"><BR><FONT size=3>    </FONT></SPAN><FONT size=3><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> sum </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">0</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000">;<BR><BR>    </SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">void</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000"> run() {<BR>        </SPAN><SPAN style="COLOR: #0000ff">try</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000"> {<BR>            </SPAN><SPAN style="COLOR: #0000ff">long</SPAN><SPAN style="COLOR: #000000"> s </SPAN><SPAN style="COLOR: #000000">=</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000"> System.currentTimeMillis();<BR>            com.cea.repository.test.testdata.MainExecute.main(</SPAN><SPAN style="COLOR: #0000ff">null</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000">);<BR>            </SPAN><SPAN style="COLOR: #0000ff">long</SPAN><SPAN style="COLOR: #000000"> t </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> System.currentTimeMillis() </SPAN><SPAN style="COLOR: #000000">-</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000"> s;<BR>            CapabilityForConnection.times </SPAN><SPAN style="COLOR: #000000">+=</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000">t;<BR></SPAN><SPAN style="COLOR: #008000">//</SPAN></FONT><FONT size=3><SPAN style="COLOR: #008000">            if(CapabilityForConnection.times < t){<BR></SPAN><SPAN style="COLOR: #008000">//</SPAN></FONT><FONT size=3><SPAN style="COLOR: #008000">                CapabilityForConnection.times = t;<BR></SPAN><SPAN style="COLOR: #008000">//</SPAN></FONT><FONT size=3><SPAN style="COLOR: #008000">            }<BR><BR></SPAN><SPAN style="COLOR: #008000">//</SPAN></FONT><FONT size=3><SPAN style="COLOR: #008000">            log.info("time" + (++sum) + ":" +<BR></SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">                               (System.currentTimeMillis() - s));</SPAN></FONT><SPAN style="COLOR: #008000"><BR></SPAN><FONT size=3><SPAN style="COLOR: #000000">        } </SPAN><SPAN style="COLOR: #0000ff">catch</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000"> (Exception ex) {<BR>        }<BR>    }<BR><BR>    </SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000"> main(String[] args) </SPAN><SPAN style="COLOR: #0000ff">throws</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000"> Exception {<BR>        </SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">(args</SPAN><SPAN style="COLOR: #000000">!=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">null</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">&&</SPAN><SPAN style="COLOR: #000000"> args.length</SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000">1</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000">){<BR>            EXECUTESUM </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> Integer.parseInt(args[</SPAN><SPAN style="COLOR: #000000">0</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000">]);<BR>            CONNECTIONS </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> Integer.parseInt(args[</SPAN><SPAN style="COLOR: #000000">1</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000">]);<BR>        }<BR><BR>        PoolSupper.initPool();<BR>        startExec(EXECUTESUM);<BR>        </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">设定足够长的时间等待所有程序执行完，得到准确的并发执行所消耗的时间</SPAN></FONT><SPAN style="COLOR: #008000"><BR></SPAN><FONT size=3><SPAN style="COLOR: #000000">        </SPAN><SPAN style="COLOR: #0000ff">try</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000"> {<BR>            Thread.sleep(</SPAN><SPAN style="COLOR: #000000">6000</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000">);<BR>        } </SPAN><SPAN style="COLOR: #0000ff">catch</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000"> (InterruptedException ex) {<BR>            ex.printStackTrace();<BR>        }<BR>        log.info(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">运行平均耗时：</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000"> CapabilityForConnection.times</SPAN><SPAN style="COLOR: #000000">/</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000">EXECUTESUM);<BR>        </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">如果条件成立，证明连接没有被回收，只要存在一个相同的，就证明连接被重复利用了</SPAN></FONT><SPAN style="COLOR: #008000"><BR></SPAN><FONT size=3><SPAN style="COLOR: #000000">        CapabilityForConnection.psize </SPAN><SPAN style="COLOR: #000000">+=</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000">poolTestMap.size();<BR>        </SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000"> (poolTestMap.size() </SPAN><SPAN style="COLOR: #000000">==</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000"> EXECUTESUM) {<BR>            log.info(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">不存在重复使用的连接，共创建</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000"> poolTestMap.size()</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">个连接</SPAN><SPAN style="COLOR: #000000">"</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000"> );<BR>        } </SPAN><SPAN style="COLOR: #0000ff">else</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000"> {<BR>            log.info(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">共使用</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000"> poolTestMap.size()</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">个连接</SPAN><SPAN style="COLOR: #000000">"</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000"> );<BR>        }<BR>        clear();<BR>    }<BR><BR>    </SPAN><SPAN style="COLOR: #0000ff">private</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000"> startExec(</SPAN><SPAN style="COLOR: #0000ff">int</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000"> EXECUTESUM) {<BR>        </SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> i </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">0</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000">;<BR>        </SPAN><SPAN style="COLOR: #0000ff">while</SPAN><SPAN style="COLOR: #000000"> (i </SPAN><SPAN style="COLOR: #000000"><</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000"> EXECUTESUM) {<BR>            </SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000"> (i</SPAN><SPAN style="COLOR: #000000">++</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000"><</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000"> EXECUTESUM) {<BR>                </SPAN><SPAN style="COLOR: #0000ff">try</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000"> {<BR>                    </SPAN><SPAN style="COLOR: #0000ff">new</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000"> PoolTest().start();<BR>                } </SPAN><SPAN style="COLOR: #0000ff">catch</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000"> (Exception ex2) {<BR>                }<BR>            }<BR>        }<BR>    }<BR>    </SPAN><SPAN style="COLOR: #0000ff">private</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">void</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000"> clear() {<BR>        poolTestMap </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">new</SPAN></FONT><SPAN style="COLOR: #000000"><FONT size=3> HashMap();<BR>    }<BR><BR><BR>}</FONT></SPAN></DIV>
<P></P>简单的不能再简单的测试代码：<BR>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><SPAN style="COLOR: #0000ff"><FONT size=3>package</FONT></SPAN><FONT size=3><SPAN style="COLOR: #000000"> com.cea.repository.test.testdata;<BR><BR></SPAN><SPAN style="COLOR: #0000ff">import</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000"> com.cea.repository.connection.drive.ConnectionFactory;<BR></SPAN><SPAN style="COLOR: #0000ff">import</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000"> java.sql.Connection;<BR></SPAN><SPAN style="COLOR: #0000ff">import</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000"> java.sql.Statement;<BR></SPAN><SPAN style="COLOR: #0000ff">import</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000"> java.sql.ResultSet;<BR></SPAN><SPAN style="COLOR: #0000ff">import</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000"> java.sql.PreparedStatement;<BR></SPAN><SPAN style="COLOR: #0000ff">import</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000"> java.util.HashMap;<BR></SPAN><SPAN style="COLOR: #0000ff">import</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000"> java.util.Map;</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #0000ff">import</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000"> java.util.List;<BR></SPAN><SPAN style="COLOR: #0000ff">import</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000"> java.util.ArrayList;<BR></SPAN><SPAN style="COLOR: #0000ff">import</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000"> com.cea.repository.test.PoolTest;<BR></SPAN><SPAN style="COLOR: #0000ff">import</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000"> com.cea.repository.connection.poolpository.PoolFactory;<BR><BR></SPAN><SPAN style="COLOR: #008000">/**</SPAN></FONT><SPAN style="COLOR: #008000"><BR><FONT size=3> * <BR> * 
<P>Title: </P><BR> * 
<P>Description: </P><BR> * 
<P>Copyright: Copyright (c) 2004</P><BR> * 
<P>Company: cea</P><BR> * </FONT></SPAN><SPAN style="COLOR: #808080"><FONT size=3>@author</FONT></SPAN><FONT size=3><SPAN style="COLOR: #008000"> 小舟<BR> * </SPAN><SPAN style="COLOR: #808080">@version</SPAN></FONT><FONT size=3><SPAN style="COLOR: #008000"> 1.0<BR> </SPAN><SPAN style="COLOR: #008000">*/</SPAN></FONT><SPAN style="COLOR: #000000"><BR></SPAN><FONT size=3><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">class</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000"> MainExecute {<BR>    </SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000"> main(String[] args) </SPAN><SPAN style="COLOR: #0000ff">throws</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000"> Exception {<BR>       testConnection();<BR>    }<BR><BR>    </SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000"> testConnection() </SPAN><SPAN style="COLOR: #0000ff">throws</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000"> Exception {<BR>        </SPAN><SPAN style="COLOR: #0000ff">for</SPAN><SPAN style="COLOR: #000000"> (</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> i </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">; i </SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #000000"> PoolTest.CONNECTIONS; i</SPAN><SPAN style="COLOR: #000000">++</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000">) {<BR>            Connection con </SPAN><SPAN style="COLOR: #000000">=</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000"> PoolFactory.newInstance();<BR>            </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">这里的改变直接影响连接的复用</SPAN></FONT><SPAN style="COLOR: #008000"><BR></SPAN><FONT size=3><SPAN style="COLOR: #000000">            Thread.sleep(</SPAN><SPAN style="COLOR: #000000">50</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000">);<BR>            PoolTest.poolTestMap.put(con.toString(), </SPAN><SPAN style="COLOR: #000000">""</SPAN></FONT><FONT size=3><SPAN style="COLOR: #000000">);<BR>            con.close();<BR>        }<BR>    }<BR></SPAN></FONT><SPAN style="COLOR: #000000"><FONT size=3><BR>}<BR></FONT></SPAN></DIV><BR>三个配置文件的内容：<BR>init.properties文件<BR>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><FONT size=3><SPAN style="COLOR: #000000">#运行的次数<BR>init</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">5</SPAN></FONT><SPAN style="COLOR: #000000"><BR><FONT size=3>#并发执行MainExecute的数量所匹配的名字<BR>name0</FONT></SPAN><SPAN style="COLOR: #000000"><FONT size=3>=</FONT></SPAN><FONT size=3><SPAN style="COLOR: #000000">execsum<BR>#一次MainExecute执行所请求的连接数所匹配的名字<BR>name1</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">opencon</SPAN></FONT></DIV><BR>reference.properties文件<BR>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><FONT size=3><SPAN style="COLOR: #000000">#过滤数据<BR>execsum0</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">10</SPAN></FONT><SPAN style="COLOR: #000000"><BR><FONT size=3>opencon0</FONT></SPAN><FONT size=3><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">1</SPAN></FONT><SPAN style="COLOR: #000000"><BR><FONT size=3>#第一次测试数据<BR>execsum1</FONT></SPAN><FONT size=3><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">100</SPAN></FONT><SPAN style="COLOR: #000000"><BR><FONT size=3>opencon1</FONT></SPAN><FONT size=3><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">6</SPAN></FONT><SPAN style="COLOR: #000000"><BR><FONT size=3>#第二次测试数据<BR>execsum2</FONT></SPAN><FONT size=3><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">85</SPAN></FONT><SPAN style="COLOR: #000000"><BR><FONT size=3>opencon2</FONT></SPAN><FONT size=3><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">9</SPAN></FONT><SPAN style="COLOR: #000000"><BR><FONT size=3>#第三次测试数据<BR>execsum3</FONT></SPAN><FONT size=3><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">140</SPAN></FONT><SPAN style="COLOR: #000000"><BR><FONT size=3>opencon3</FONT></SPAN><FONT size=3><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">3</SPAN></FONT></DIV><BR>最后一个是pool-config.xml数据源配置：<BR>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><FONT size=3><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #0000ff"><?</SPAN><SPAN style="COLOR: #ff00ff">xml version="1.0" encoding="GB2312"</SPAN><SPAN style="COLOR: #0000ff">?></SPAN></FONT><SPAN style="COLOR: #000000"><BR><FONT size=3><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></FONT></SPAN><FONT size=3><SPAN style="COLOR: #0000ff"><</SPAN><SPAN style="COLOR: #800000">DataResources</SPAN><SPAN style="COLOR: #0000ff">></SPAN></FONT><SPAN style="COLOR: #000000"><BR><FONT size=3><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>  </FONT></SPAN><FONT size=3><SPAN style="COLOR: #0000ff"><</SPAN><SPAN style="COLOR: #800000">ResourceParams </SPAN><SPAN style="COLOR: #ff0000">dateIndentity</SPAN><SPAN style="COLOR: #0000ff">="boat1"</SPAN><SPAN style="COLOR: #0000ff">></SPAN></FONT><SPAN style="COLOR: #000000"><BR><FONT size=3><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>    </FONT></SPAN><FONT size=3><SPAN style="COLOR: #0000ff"><</SPAN><SPAN style="COLOR: #800000">defaultAutoCommit</SPAN><SPAN style="COLOR: #0000ff">></SPAN><SPAN style="COLOR: #000000">false</SPAN><SPAN style="COLOR: #0000ff"></< SPAN><SPAN style="COLOR: #800000">defaultAutoCommit</SPAN><SPAN style="COLOR: #0000ff">></SPAN></FONT><SPAN style="COLOR: #000000"><BR><FONT size=3><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>    </FONT></SPAN><FONT size=3><SPAN style="COLOR: #0000ff"><</SPAN><SPAN style="COLOR: #800000">initialSize</SPAN><SPAN style="COLOR: #0000ff">></SPAN><SPAN style="COLOR: #000000">30</SPAN><SPAN style="COLOR: #0000ff"></< SPAN><SPAN style="COLOR: #800000">initialSize</SPAN><SPAN style="COLOR: #0000ff">></SPAN></FONT><SPAN style="COLOR: #000000"><BR><FONT size=3><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>    </FONT></SPAN><FONT size=3><SPAN style="COLOR: #0000ff"><</SPAN><SPAN style="COLOR: #800000">maxActive</SPAN><SPAN style="COLOR: #0000ff">></SPAN><SPAN style="COLOR: #000000">40</SPAN><SPAN style="COLOR: #0000ff"></< SPAN><SPAN style="COLOR: #800000">maxActive</SPAN><SPAN style="COLOR: #0000ff">></SPAN></FONT><SPAN style="COLOR: #000000"><BR><FONT size=3><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>    </FONT></SPAN><FONT size=3><SPAN style="COLOR: #0000ff"><</SPAN><SPAN style="COLOR: #800000">minIdle</SPAN><SPAN style="COLOR: #0000ff">></SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #0000ff"></< SPAN><SPAN style="COLOR: #800000">minIdle</SPAN><SPAN style="COLOR: #0000ff">></SPAN></FONT><SPAN style="COLOR: #000000"><BR><FONT size=3><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>    </FONT></SPAN><FONT size=3><SPAN style="COLOR: #0000ff"><</SPAN><SPAN style="COLOR: #800000">maxIdle</SPAN><SPAN style="COLOR: #0000ff">></SPAN><SPAN style="COLOR: #000000">18</SPAN><SPAN style="COLOR: #0000ff"></< SPAN><SPAN style="COLOR: #800000">maxIdle</SPAN><SPAN style="COLOR: #0000ff">></SPAN></FONT><SPAN style="COLOR: #000000"><BR><FONT size=3><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>    </FONT></SPAN><FONT size=3><SPAN style="COLOR: #0000ff"><</SPAN><SPAN style="COLOR: #800000">maxWait</SPAN><SPAN style="COLOR: #0000ff">></SPAN><SPAN style="COLOR: #000000">10000</SPAN><SPAN style="COLOR: #0000ff"></< SPAN><SPAN style="COLOR: #800000">maxWait</SPAN><SPAN style="COLOR: #0000ff">></SPAN></FONT><SPAN style="COLOR: #000000"><BR><FONT size=3><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>    </FONT></SPAN><FONT size=3><SPAN style="COLOR: #0000ff"><</SPAN><SPAN style="COLOR: #800000">username</SPAN><SPAN style="COLOR: #0000ff">></SPAN><SPAN style="COLOR: #000000">forum</SPAN><SPAN style="COLOR: #0000ff"></< SPAN><SPAN style="COLOR: #800000">username</SPAN><SPAN style="COLOR: #0000ff">></SPAN></FONT><SPAN style="COLOR: #000000"><BR><FONT size=3><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>    </FONT></SPAN><FONT size=3><SPAN style="COLOR: #0000ff"><</SPAN><SPAN style="COLOR: #800000">password</SPAN><SPAN style="COLOR: #0000ff">></SPAN><SPAN style="COLOR: #000000">king</SPAN><SPAN style="COLOR: #0000ff"></< SPAN><SPAN style="COLOR: #800000">password</SPAN><SPAN style="COLOR: #0000ff">></SPAN></FONT><SPAN style="COLOR: #000000"><BR><FONT size=3><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>    </FONT></SPAN><FONT size=3><SPAN style="COLOR: #0000ff"><</SPAN><SPAN style="COLOR: #800000">driverClassName</SPAN><SPAN style="COLOR: #0000ff">></SPAN><SPAN style="COLOR: #000000">oracle.jdbc.driver.OracleDriver</SPAN><SPAN style="COLOR: #0000ff"></< SPAN><SPAN style="COLOR: #800000">driverClassName</SPAN><SPAN style="COLOR: #0000ff">></SPAN></FONT><SPAN style="COLOR: #000000"><BR><FONT size=3><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>    </FONT></SPAN><FONT size=3><SPAN style="COLOR: #0000ff"><</SPAN><SPAN style="COLOR: #800000">url</SPAN><SPAN style="COLOR: #0000ff">></SPAN><SPAN style="COLOR: #000000">jdbc:oracle:thin:@192.168.1.3:1521:gzest</SPAN><SPAN style="COLOR: #0000ff"></< SPAN><SPAN style="COLOR: #800000">url</SPAN><SPAN style="COLOR: #0000ff">></SPAN></FONT><SPAN style="COLOR: #000000"><BR><FONT size=3><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>    </FONT></SPAN><FONT size=3><SPAN style="COLOR: #0000ff"><</SPAN><SPAN style="COLOR: #800000">removeAbandoned</SPAN><SPAN style="COLOR: #0000ff">></SPAN><SPAN style="COLOR: #000000">true</SPAN><SPAN style="COLOR: #0000ff"></< SPAN><SPAN style="COLOR: #800000">removeAbandoned</SPAN><SPAN style="COLOR: #0000ff">></SPAN></FONT><SPAN style="COLOR: #000000"><BR><FONT size=3><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>    </FONT></SPAN><FONT size=3><SPAN style="COLOR: #0000ff"><</SPAN><SPAN style="COLOR: #800000">removeAbandonedTimeout</SPAN><SPAN style="COLOR: #0000ff">></SPAN><SPAN style="COLOR: #000000">10</SPAN><SPAN style="COLOR: #0000ff"></< SPAN><SPAN style="COLOR: #800000">removeAbandonedTimeout</SPAN><SPAN style="COLOR: #0000ff">></SPAN></FONT><SPAN style="COLOR: #000000"><BR><FONT size=3><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>    </FONT></SPAN><FONT size=3><SPAN style="COLOR: #0000ff"><</SPAN><SPAN style="COLOR: #800000">logAbandoned</SPAN><SPAN style="COLOR: #0000ff">></SPAN><SPAN style="COLOR: #000000">true</SPAN><SPAN style="COLOR: #0000ff"></< SPAN><SPAN style="COLOR: #800000">logAbandoned</SPAN><SPAN style="COLOR: #0000ff">></SPAN></FONT><SPAN style="COLOR: #000000"><BR><FONT size=3><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>  </FONT></SPAN><FONT size=3><SPAN style="COLOR: #0000ff"></< SPAN><SPAN style="COLOR: #800000">ResourceParams</SPAN><SPAN style="COLOR: #0000ff">></SPAN></FONT><SPAN style="COLOR: #000000"><BR><FONT size=3><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></FONT></SPAN><FONT size=3><SPAN style="COLOR: #0000ff"></< SPAN><SPAN style="COLOR: #800000">DataResources</SPAN><SPAN style="COLOR: #0000ff">></SPAN></FONT><SPAN style="COLOR: #000000"><BR><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN></DIV></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN><img src ="http://www.blogjava.net/cyicecream/aggbug/14152.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/cyicecream/" target="_blank">ceaboat</a> 2005-09-26 22:36 <a href="http://www.blogjava.net/cyicecream/archive/2005/09/26/14152.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>影响性能的测试报告（数据库版）</title><link>http://www.blogjava.net/cyicecream/archive/2005/09/25/14000.html</link><dc:creator>ceaboat</dc:creator><author>ceaboat</author><pubDate>Sun, 25 Sep 2005 09:21:00 GMT</pubDate><guid>http://www.blogjava.net/cyicecream/archive/2005/09/25/14000.html</guid><wfw:comment>http://www.blogjava.net/cyicecream/comments/14000.html</wfw:comment><comments>http://www.blogjava.net/cyicecream/archive/2005/09/25/14000.html#Feedback</comments><slash:comments>4</slash:comments><wfw:commentRss>http://www.blogjava.net/cyicecream/comments/commentRss/14000.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/cyicecream/services/trackbacks/14000.html</trackback:ping><description><![CDATA[<H1 style="MARGIN: 17pt 0cm 16.5pt"><SPAN style="FONT-SIZE: 22pt; FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;影响性能的测试报告（数据库版）</SPAN></H1>
<H1 style="MARGIN: 17pt 0cm 16.5pt"><SPAN style="FONT-SIZE: 22pt; FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"></SPAN><A name=_Toc115427584><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt">引言</SPAN></A><SPAN style="mso-bookmark: _Toc115427584"></SPAN><SPAN lang=EN-US style="mso-font-kerning: 0pt"><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></H1>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">如需转载，请与<A href="mailto:cyicecream@163.com">笔者</A>联系<BR></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt">&nbsp;</P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">前提：项目组里无用到</SPAN><SPAN lang=EN-US><FONT face="Times New Roman">SPRING</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">进行事务的管理。项目里以功能划分到每个人手里，</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 32.25pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">形成了</SPAN><SPAN lang=EN-US><FONT face="Times New Roman">BO</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，</SPAN><SPAN lang=EN-US><FONT face="Times New Roman">DAO</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，</SPAN><SPAN lang=EN-US><FONT face="Times New Roman">ACTION</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，</SPAN><SPAN lang=EN-US><FONT face="Times New Roman">VIEW</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">都是单人负责。在</SPAN><SPAN lang=EN-US><FONT face="Times New Roman">DAO</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中每个动作都以</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-SIZE: 10.5pt; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 1.0pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;封闭式的形式存在。</P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">问题：造成事务的不连贯性。功能是做出来了，性能问题迟早暴露。</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">测试：主要针对程序频繁请求数据库连接对</SPAN><SPAN lang=EN-US><FONT face="Times New Roman">WEB</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">应用所造成影响做一个测试。</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><FONT face="Times New Roman">&nbsp;<o:p></o:p></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><FONT face="Times New Roman">&nbsp;<o:p></o:p></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-SIZE: 10.5pt; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 1.0pt">先做必要的说明，一步步引入正题，先从性能瓶颈开始：</SPAN></SPAN></SPAN></P>
<H1 style="MARGIN: 17pt 0cm 16.5pt"><A name=_Toc115427585><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt">性能瓶颈</SPAN></A><SPAN style="mso-bookmark: _Toc115427585"></SPAN><SPAN lang=EN-US style="mso-font-kerning: 0pt"><o:p></o:p></SPAN></H1>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">所有的应用程序都存在性能瓶颈，为了提高应用程序的性能，就要尽可能的减少程序的瓶颈。以下是在<SPAN lang=EN-US>JAVA程序中经常存在的性能瓶颈。<o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt"><IMG height=154 alt=pingjing.jpg src="http://www.blogjava.net/images/blogjava_net/cyicecream/pingjing.jpg" width=515 border=0><BR>了解了这些瓶颈后，就可以有针对性的减少这些瓶颈，从而提高<SPAN lang=EN-US>JAVA应用程序的性能<o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">&nbsp;<o:p></o:p></SPAN></P>
<H1 style="MARGIN: 17pt 0cm 16.5pt"><A name=_Toc115427586><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt">数据库连接池工作原理</SPAN></A><SPAN style="mso-bookmark: _Toc115427586"></SPAN><SPAN lang=EN-US style="mso-font-kerning: 0pt"><o:p></o:p></SPAN></H1>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left" align=left><SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">关于连接池的实现原理测试方案：</SPAN><SPAN lang=EN-US style="FONT-SIZE: 12pt"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left" align=left><SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">经过资料的收集与</SPAN><SPAN lang=EN-US style="FONT-SIZE: 12pt">APACHE DBCP</SPAN><SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">里连接池的查阅，对现有的连接池工作</SPAN><SPAN lang=EN-US style="FONT-SIZE: 12pt"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left" align=left><SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">原理有两种方式：</SPAN><SPAN lang=EN-US style="FONT-SIZE: 12pt"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: -21pt; TEXT-ALIGN: left; mso-list: l4 level1 lfo3; tab-stops: list 21.0pt" align=left><SPAN lang=EN-US style="FONT-SIZE: 12pt">1.<SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN><SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">数据库预先设置配置好的连接数。待得到用户请求连接，传出一个连接，而后为了保持供应数再提前创建连接，即提前预备连接数供请求。比如：</SPAN><SPAN lang=EN-US style="FONT-SIZE: 12pt"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-ALIGN: left" align=left><SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">有</SPAN><SPAN lang=EN-US style="FONT-SIZE: 12pt">5</SPAN><SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">个通行道代表最大激活的连接数，最小</SPAN><SPAN lang=EN-US style="FONT-SIZE: 12pt">2</SPAN><SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">个闲置连接数。也就是说连接池里始终预备了</SPAN><SPAN lang=EN-US style="FONT-SIZE: 12pt">2</SPAN><SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">个可随时提供的连接，连接的创建开销是比较大的，连接池的存在就是了能够最小化的解决创建所等待的时间。</SPAN><SPAN lang=EN-US style="FONT-SIZE: 12pt"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left" align=left><SPAN lang=EN-US style="FONT-SIZE: 12pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;</SPAN></SPAN><SPAN lang=EN-US style="FONT-SIZE: 12pt">1<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>O<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left" align=left><SPAN lang=EN-US style="FONT-SIZE: 12pt"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>2<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>O<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left" align=left><SPAN lang=EN-US style="FONT-SIZE: 12pt"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>3<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>*<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left" align=left><SPAN lang=EN-US style="FONT-SIZE: 12pt"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>4<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>*<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left" align=left><SPAN lang=EN-US style="FONT-SIZE: 12pt"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>5<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>*<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left" align=left><SPAN lang=EN-US style="FONT-SIZE: 12pt"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN></SPAN><SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">如上图，当</SPAN><SPAN lang=EN-US style="FONT-SIZE: 12pt">1</SPAN><SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">分配出去时由于池中连接数剩一个，为保持最小闲置，会自动创建一个新的连接以防止再次请求等待创建的时间。这样确实减少了等待的时间，但是数据库创建的开销方面并未得到解决。如果把</SPAN><SPAN lang=EN-US style="FONT-SIZE: 12pt">1-5</SPAN><SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">比喻成汽车，那么这种情况下每量车都是一次性使用。</SPAN><SPAN lang=EN-US style="FONT-SIZE: 12pt">1</SPAN><SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">被请求后下一个连接将是</SPAN><SPAN lang=EN-US style="FONT-SIZE: 12pt">6</SPAN><SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">来接替。那么如何能够重复利用</SPAN><SPAN lang=EN-US style="FONT-SIZE: 12pt">1</SPAN><SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">减少数据库开销。于是引出第二种方式。</SPAN><SPAN lang=EN-US style="FONT-SIZE: 12pt"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left" align=left><SPAN lang=EN-US style="FONT-SIZE: 12pt">&nbsp;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: -21pt; TEXT-ALIGN: left; mso-list: l4 level1 lfo3; tab-stops: list 21.0pt" align=left><SPAN lang=EN-US style="FONT-SIZE: 12pt">2.<SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN><SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">回收使用完后的连接，放回到池中进行循环利用。这么做必须能保证</SPAN><SPAN lang=EN-US style="FONT-SIZE: 12pt">2</SPAN><SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">点</SPAN><SPAN lang=EN-US style="FONT-SIZE: 12pt"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left" align=left><SPAN lang=EN-US style="FONT-SIZE: 12pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN></SPAN><SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">一</SPAN><SPAN lang=EN-US style="FONT-SIZE: 12pt">.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN></SPAN><SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">使连接能够保持有效的回收。</SPAN><SPAN lang=EN-US style="FONT-SIZE: 12pt"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left" align=left><SPAN lang=EN-US style="FONT-SIZE: 12pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN></SPAN><SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">二</SPAN><SPAN lang=EN-US style="FONT-SIZE: 12pt">.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN></SPAN><SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">约束使用者使用释放的动作，而不是直接把连接</SPAN><SPAN lang=EN-US style="FONT-SIZE: 12pt">close.<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left" align=left><SPAN lang=EN-US style="FONT-SIZE: 12pt">&nbsp;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left" align=left><SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">本人使用的是</SPAN><SPAN lang=EN-US style="FONT-SIZE: 12pt">APACHE DBCP</SPAN><SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">里</SPAN><SPAN lang=EN-US style="FONT-SIZE: 12pt">BasicDataSource</SPAN><SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的连接池基本实现，</SPAN><SPAN lang=EN-US style="FONT-SIZE: 12pt"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left" align=left><SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">经过代码与测试结果显示，其工作方式是基于二的。</SPAN><SPAN lang=EN-US style="FONT-SIZE: 12pt"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left" align=left><SPAN lang=EN-US style="FONT-SIZE: 12pt">&nbsp;<o:p></o:p></SPAN></P>
<H1 style="MARGIN: 17pt 0cm 16.5pt"><A name=_Toc115427587><SPAN lang=EN-US>BasicDataSource</SPAN></A><SPAN style="mso-bookmark: _Toc115427587"><SPAN style="FONT-FAMILY: 宋体; mso-bidi-font-size: 10.5pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">测试用例</SPAN></SPAN><SPAN style="mso-bookmark: _Toc115427587"></SPAN><SPAN lang=EN-US style="mso-bidi-font-size: 10.5pt"><o:p></o:p></SPAN></H1>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">请看</SPAN><SPAN lang=EN-US><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><A href="http://www.blogjava.net/cyicecream/cyicecream/cyicecream/cyicecream/archive/2005/09/26/14152.html">测试用例</A></SPAN></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><BR><BR>测试结果：</SPAN><BR></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><BR>第</SPAN><SPAN lang=EN-US>2</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">组数据</SPAN><SPAN lang=EN-US>:</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="COLOR: #ff6600; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">并发应用数：</SPAN><SPAN lang=EN-US style="COLOR: #ff6600">100 </SPAN><SPAN style="COLOR: #ff6600; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">模拟连接数：</SPAN><SPAN lang=EN-US style="COLOR: #ff6600">6<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">运行平均耗时：</SPAN><SPAN lang=EN-US>2956</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">共使用</SPAN><SPAN lang=EN-US>51</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">个连接</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">运行平均耗时：</SPAN><SPAN lang=EN-US>3391</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US>2</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">共使用</SPAN><SPAN lang=EN-US>52</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">个连接</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">运行平均耗时：</SPAN><SPAN lang=EN-US>2616</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">共使用</SPAN><SPAN lang=EN-US>47</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">个连接</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">运行平均耗时：</SPAN><SPAN lang=EN-US>3377</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">共使用</SPAN><SPAN lang=EN-US>41</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">个连接</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">运行平均耗时：</SPAN><SPAN lang=EN-US>3673</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">共使用</SPAN><SPAN lang=EN-US>46</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">个连接</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="COLOR: #ff6600; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">第</SPAN><SPAN lang=EN-US style="COLOR: #ff6600">2</SPAN><SPAN style="COLOR: #ff6600; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">组数据共执行</SPAN><SPAN lang=EN-US style="COLOR: #ff6600">5</SPAN><SPAN style="COLOR: #ff6600; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">次</SPAN><SPAN lang=EN-US style="COLOR: #ff6600">;</SPAN><SPAN style="COLOR: #ff6600; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">平均耗时为：</SPAN><SPAN lang=EN-US style="COLOR: #ff6600">3229</SPAN><SPAN style="COLOR: #ff6600; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">毫秒</SPAN><SPAN lang=EN-US style="COLOR: #ff6600"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="COLOR: #ff6600; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">平均使用</SPAN><SPAN lang=EN-US style="COLOR: #ff6600">47</SPAN><SPAN style="COLOR: #ff6600; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">个连接</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US>&nbsp;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">第</SPAN><SPAN lang=EN-US>3</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">组数据</SPAN><SPAN lang=EN-US>:</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="COLOR: #ff6600; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">并发应用数：</SPAN><SPAN lang=EN-US style="COLOR: #ff6600">85 </SPAN><SPAN style="COLOR: #ff6600; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">模拟连接数：</SPAN><SPAN lang=EN-US style="COLOR: #ff6600">9<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">运行平均耗时：</SPAN><SPAN lang=EN-US>4830</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">共使用</SPAN><SPAN lang=EN-US>53</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">个连接</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">运行平均耗时：</SPAN><SPAN lang=EN-US>3247</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">共使用</SPAN><SPAN lang=EN-US>49</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">个连接</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">运行平均耗时：</SPAN><SPAN lang=EN-US>4116</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">共使用</SPAN><SPAN lang=EN-US>40</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">个连接</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">运行平均耗时：</SPAN><SPAN lang=EN-US>4070</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">共使用</SPAN><SPAN lang=EN-US>43</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">个连接</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">运行平均耗时：</SPAN><SPAN lang=EN-US>4053</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">共使用</SPAN><SPAN lang=EN-US>54</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">个连接</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="COLOR: #ff6600; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">第</SPAN><SPAN lang=EN-US style="COLOR: #ff6600">3</SPAN><SPAN style="COLOR: #ff6600; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">组数据共执行</SPAN><SPAN lang=EN-US style="COLOR: #ff6600">5</SPAN><SPAN style="COLOR: #ff6600; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">次</SPAN><SPAN lang=EN-US style="COLOR: #ff6600">;</SPAN><SPAN style="COLOR: #ff6600; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">平均耗时为：</SPAN><SPAN lang=EN-US style="COLOR: #ff6600">4063</SPAN><SPAN style="COLOR: #ff6600; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">毫秒</SPAN><SPAN lang=EN-US style="COLOR: #ff6600"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="COLOR: #ff6600; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">平均使用</SPAN><SPAN lang=EN-US style="COLOR: #ff6600">47</SPAN><SPAN style="COLOR: #ff6600; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">个连接</SPAN><SPAN lang=EN-US style="COLOR: #ff6600"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US>&nbsp;<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">第</SPAN><SPAN lang=EN-US>4</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">组数据</SPAN><SPAN lang=EN-US>:</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="COLOR: #ff6600; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">并发应用数：</SPAN><SPAN lang=EN-US style="COLOR: #ff6600">140 </SPAN><SPAN style="COLOR: #ff6600; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">模拟连接数：</SPAN><SPAN lang=EN-US style="COLOR: #ff6600">3<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">运行平均耗时：</SPAN><SPAN lang=EN-US>2076</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">共使用</SPAN><SPAN lang=EN-US>47</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">个连接</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">运行平均耗时：</SPAN><SPAN lang=EN-US>3104</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">共使用</SPAN><SPAN lang=EN-US>51</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">个连接</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">运行平均耗时：</SPAN><SPAN lang=EN-US>2048</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">共使用</SPAN><SPAN lang=EN-US>43</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">个连接</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">运行平均耗时：</SPAN><SPAN lang=EN-US>2421</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">共使用</SPAN><SPAN lang=EN-US>50</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">个连接</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">运行平均耗时：</SPAN><SPAN lang=EN-US>2751</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">共使用</SPAN><SPAN lang=EN-US>50</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">个连接</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="COLOR: #ff6600; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">第</SPAN><SPAN lang=EN-US style="COLOR: #ff6600">4</SPAN><SPAN style="COLOR: #ff6600; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">组数据共执行</SPAN><SPAN lang=EN-US style="COLOR: #ff6600">5</SPAN><SPAN style="COLOR: #ff6600; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">次</SPAN><SPAN lang=EN-US style="COLOR: #ff6600">;</SPAN><SPAN style="COLOR: #ff6600; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">平均耗时为：</SPAN><SPAN lang=EN-US style="COLOR: #ff6600">2480</SPAN><SPAN style="COLOR: #ff6600; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">毫秒</SPAN><SPAN lang=EN-US style="COLOR: #ff6600"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="COLOR: #ff6600; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">平均使用</SPAN><SPAN lang=EN-US style="COLOR: #ff6600">48</SPAN><SPAN style="COLOR: #ff6600; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">个连接</SPAN><SPAN lang=EN-US style="COLOR: #ff6600"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US style="COLOR: #ff6600">&nbsp;<o:p></o:p></SPAN></P><SPAN style="COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="COLOR: black; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">每次测试的结果都可能不同，但是所得到的结论是一致的。数据显示不合理的请求使用连接严重的影响应用所能承受的并发数量，响应的时间也因此受到影响。</SPAN><SPAN lang=EN-US style="COLOR: black"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"></SPAN><SPAN lang=EN-US style="COLOR: black"><o:p></o:p></SPAN>&nbsp;</P>
<H1 style="MARGIN: 17pt 0cm 16.5pt"><A name=_Toc115427588><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt">目前普遍存在的问题</SPAN></A><SPAN style="mso-bookmark: _Toc115427588"></SPAN><SPAN lang=EN-US style="mso-font-kerning: 0pt"><o:p></o:p></SPAN></H1>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">没有把事务控制好，一般会出现以下的情况：</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 18pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">事务</SPAN><SPAN lang=EN-US>(){</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 18pt"><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp; </SPAN></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">流程</SPAN><SPAN lang=EN-US>1();</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 18pt"><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp; </SPAN></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">流程</SPAN><SPAN lang=EN-US>2();</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 18pt"><SPAN lang=EN-US>}</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 18pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">可以看出流程</SPAN><SPAN lang=EN-US>1</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，</SPAN><SPAN lang=EN-US>2</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">里都是单独创建连接，并在自己的流程里完成操作。</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 18pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">如果在流程</SPAN><SPAN lang=EN-US>2</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">里出现异常，那么流程</SPAN><SPAN lang=EN-US>1</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">所做的操作是不可恢复的。</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 18pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">如果能控制在事务范围内，如：</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 18pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">事务</SPAN><SPAN lang=EN-US>(){</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 18pt"><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Connection con;</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 18pt"><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp; </SPAN></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">流程</SPAN><SPAN lang=EN-US>1(con);</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 18pt"><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp; </SPAN></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">流程</SPAN><SPAN lang=EN-US>2(con);</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 18pt"><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>con.close();</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 18pt"><SPAN lang=EN-US>}</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 18pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">那么数据库少提供一个连接，事务的完成性也得到体现。在并发数量大的时候，</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 18pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">效率上就有非常明显的区别。<BR></P>
<H1 style="MARGIN: 17pt 0cm 16.5pt"><A name=_Toc115427590><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">解决方案</SPAN></A></H1>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 39pt; TEXT-INDENT: -18pt; mso-list: l0 level1 lfo5; tab-stops: list 39.0pt"><SPAN lang=EN-US><FONT face="Times New Roman">1．<SPAN style="FONT: 7pt 'Times New Roman'"><FONT size=3>&nbsp; </FONT></SPAN></FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">尽量保持少的请求</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 10.5pt; mso-char-indent-count: 1.0; mso-char-indent-size: 10.5pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">如</SPAN><SPAN lang=EN-US><FONT face="Times New Roman">DAO</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中有</SPAN><SPAN lang=EN-US><FONT face="Times New Roman">update()</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">方法，则应再扩展一个方法</SPAN><SPAN lang=EN-US><FONT face="Times New Roman">update(Connection conn)</FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 39pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">在业务逻辑事务里调用</SPAN><SPAN lang=EN-US><FONT face="Times New Roman">update(Connection conn)</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，一般情况下调用</SPAN><SPAN lang=EN-US><FONT face="Times New Roman">update()</FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 39pt; TEXT-INDENT: -18pt; mso-list: l0 level1 lfo5; tab-stops: list 39.0pt"><SPAN lang=EN-US><FONT face="Times New Roman">2．<SPAN style="FONT: 7pt 'Times New Roman'"><FONT size=3>&nbsp; </FONT></SPAN></FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">对于数据不变的情况采用缓存技术，或部分缓存技术。</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 18pt"><SPAN lang=EN-US style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Times New Roman'; mso-bidi-font-size: 12.0pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-font-kerning: 1.0pt; mso-fareast-font-family: 宋体"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN><SPAN style="FONT-SIZE: 10.5pt; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 1.0pt">可参照一些相关的开源的项目（</SPAN><SPAN lang=EN-US style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Times New Roman'; mso-bidi-font-size: 12.0pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-font-kerning: 1.0pt; mso-fareast-font-family: 宋体">JIVE</SPAN><SPAN style="FONT-SIZE: 10.5pt; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 1.0pt">）。</SPAN></SPAN></P><img src ="http://www.blogjava.net/cyicecream/aggbug/14000.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/cyicecream/" target="_blank">ceaboat</a> 2005-09-25 17:21 <a href="http://www.blogjava.net/cyicecream/archive/2005/09/25/14000.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>解决JB2006启动每次注册问题</title><link>http://www.blogjava.net/cyicecream/archive/2005/09/24/13936.html</link><dc:creator>ceaboat</dc:creator><author>ceaboat</author><pubDate>Sat, 24 Sep 2005 05:45:00 GMT</pubDate><guid>http://www.blogjava.net/cyicecream/archive/2005/09/24/13936.html</guid><wfw:comment>http://www.blogjava.net/cyicecream/comments/13936.html</wfw:comment><comments>http://www.blogjava.net/cyicecream/archive/2005/09/24/13936.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.blogjava.net/cyicecream/comments/commentRss/13936.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/cyicecream/services/trackbacks/13936.html</trackback:ping><description><![CDATA[把ent.slip放入\Borland\JBuilder2006\license里<img src ="http://www.blogjava.net/cyicecream/aggbug/13936.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/cyicecream/" target="_blank">ceaboat</a> 2005-09-24 13:45 <a href="http://www.blogjava.net/cyicecream/archive/2005/09/24/13936.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>JBOAT</title><link>http://www.blogjava.net/cyicecream/archive/2005/09/15/13129.html</link><dc:creator>ceaboat</dc:creator><author>ceaboat</author><pubDate>Thu, 15 Sep 2005 15:41:00 GMT</pubDate><guid>http://www.blogjava.net/cyicecream/archive/2005/09/15/13129.html</guid><wfw:comment>http://www.blogjava.net/cyicecream/comments/13129.html</wfw:comment><comments>http://www.blogjava.net/cyicecream/archive/2005/09/15/13129.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/cyicecream/comments/commentRss/13129.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/cyicecream/services/trackbacks/13129.html</trackback:ping><description><![CDATA[<P><FONT style="BACKGROUND-COLOR: #d3d3d3" face=宋体 color=#0000ff size=4>1．运行环境：<BR>JDK，ORACLE9i以上，CASTOR包。建议使用JBUILDE<BR>工具进行开发<BR>2．使用环境：<BR>采用ORM（关系对象映射）操作数据库数据，适用于Application与WEB方式下的开发。</FONT></P>
<P><FONT style="BACKGROUND-COLOR: #d3d3d3" face=宋体 color=#0000ff size=4>3.功能：<BR>&nbsp;&nbsp;&nbsp; 提供查询，更新，删除，插入（没实现主键自动生成）,(分页暂时没实现)。4．使用步骤：<BR>首先在数据库建立一个cat表，字段为cat_id;name;sex;weight;类型1，4为数字型，2，<BR>3为字符串型。</FONT></P>
<P><FONT style="BACKGROUND-COLOR: #d3d3d3" face=宋体 color=#0000ff size=4>其次建立两个配置文件（由自己定义文件名称）：<BR>repository.xml配置信息：<BR>&lt;?xml version="1.0" encoding="UTF-8"?&gt;<BR>&lt;Repository&gt;<BR>&nbsp;&lt;TableDesc execid="CAT" identifyField="CAT_ID"&gt;<BR>&nbsp; &lt;table&gt;CAT&lt;/table&gt; <BR>&nbsp; &lt;condition /&gt; <BR>&nbsp;&lt;FieldDesc name="CAT_ID" fieldType="java.lang.String" &gt;<BR>&nbsp; &lt;title&gt;CAT_ID&lt;/title&gt; <BR>&nbsp; &lt;/FieldDesc&gt;<BR>&nbsp;&lt;FieldDesc name="NAME" fieldType="java.lang.String" &gt;<BR>&nbsp; &lt;title&gt;NAME&lt;/title&gt; <BR>&nbsp; &lt;/FieldDesc&gt;<BR>&nbsp;&lt;FieldDesc name="SEX" fieldType="java.lang.String" &gt;<BR>&nbsp; &lt;title&gt;SEX&lt;/title&gt; <BR>&nbsp; &lt;/FieldDesc&gt;<BR>&nbsp;&lt;FieldDesc name="WEIGHT" fieldType="java.lang.Long" &gt;<BR>&nbsp; &lt;title&gt;WEIGHT&lt;/title&gt; <BR>&nbsp; &lt;/FieldDesc&gt;<BR>&nbsp; &lt;/TableDesc&gt;<BR>&lt;/Repository&gt;<BR>配置文件的设计说明如下：<BR>TableDesc 表示一个表的声明。<BR>Execid 是类名一般情况下最好和表名一致（容易找到对应关系），但是不允许有下划线出现。注意这个类名不是全路径。<BR>DentifyField 表中的主键,如果是复合主键则以逗号相隔开<BR>Table 数据库表名<BR>&lt;FieldDesc name="SEX" fieldType="java.lang.String" &gt;<BR>&nbsp; &lt;title&gt;SEX&lt;/title&gt; <BR>&nbsp; &lt;/FieldDesc&gt;<BR>这里是表中字段的描述，name是字段名。 fieldType 是数据库字段对<BR>应java中的类型，只有4中类型可填充：java.lang.String, <BR>java.lang.Long, java.util.Date, java.lang.Double<BR>title可要可不要.如果存在多个表，那么就在&lt;/TableDesc&gt;和<BR>&lt;/Repository&gt;之间加入表描述。</FONT></P>
<P><FONT style="BACKGROUND-COLOR: #d3d3d3" face=宋体 color=#0000ff size=4>pool-config.xml配置信息：<BR>&lt;?xml version="1.0" encoding="GB2312"?&gt;<BR>&lt;ResourceParams&gt;<BR>&lt;maxActive&gt;10&lt;/maxActive&gt;<BR>&lt;maxIdle&gt;5&lt;/maxIdle&gt;<BR>&lt;maxWait&gt;10000&lt;/maxWait&gt;<BR>&lt;username&gt;test&lt;/username&gt;<BR>&lt;password&gt;test&lt;/password&gt;<BR>&lt;driverClassName&gt;oracle.jdbc.driver.OracleDriver&lt;/driverClassName&gt;<BR>&lt;url&gt;jdbc:oracle:thin:@192.168.0.90:1521:forecast&lt;/url&gt;<BR>&lt;removeAbandoned&gt;true&lt;/removeAbandoned&gt;<BR>&lt;removeAbandonedTimeout&gt;60&lt;/removeAbandonedTimeout&gt;<BR>&lt;logAbandoned&gt;true&lt;/logAbandoned&gt;<BR>&lt;/ResourceParams&gt;<BR>把上述信息保存为XML文件。对这个文件不多做说明了。</FONT></P>
<P><FONT style="BACKGROUND-COLOR: #d3d3d3" face=宋体 color=#0000ff size=4>确定两个文件已经存在，接下来就是要创建表CAT。<BR>还有表所对应的BEAN。<BR>下面是我在Hibernate的一个例子中建立的VO。（借用）<BR>package com.cea.boat.dao;<BR>&nbsp; import java.util.*;<BR>&nbsp; public class Cat implements Cloneable&nbsp; {<BR>&nbsp;&nbsp;&nbsp; //Declare Field<BR>&nbsp;&nbsp;&nbsp; private java.lang.String&nbsp; catId;<BR>&nbsp;&nbsp;&nbsp; private java.lang.String&nbsp; name;<BR>&nbsp;&nbsp;&nbsp; private java.lang.String&nbsp; sex;<BR>&nbsp;&nbsp;&nbsp; private java.lang.Long&nbsp; weight;<BR>&nbsp;&nbsp;&nbsp; //Get Method<BR>&nbsp;&nbsp;&nbsp; public java.lang.String getCatId() {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return catId;<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; public java.lang.String getName() {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return name;<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; public java.lang.String getSex() {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return sex;<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; public java.lang.Long getWeight() {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return weight;<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; //Set Method<BR>&nbsp;&nbsp;&nbsp; public void setCatId(java.lang.String catId) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.catId=catId;<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; public void setName(java.lang.String name) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.name=name;<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; public void setSex(java.lang.String sex) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.sex=sex;<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; public void setWeight(java.lang.Long weight) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.weight=weight;<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp; public Object clone() {<BR>&nbsp;&nbsp;&nbsp; Object o = null;<BR>&nbsp;&nbsp;&nbsp; try {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; o = super.clone();<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; catch (CloneNotSupportedException ex) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out.println(o);<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; return o;<BR>&nbsp; }<BR>&nbsp; public boolean equals(Object obj) {<BR>&nbsp;&nbsp;&nbsp; Cat o = (Cat)obj;<BR>&nbsp;&nbsp;&nbsp; boolean result = true<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &amp;&amp; (catId == o.catId || catId.equals(o.catId))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &amp;&amp; (name == o.name || name.equals(o.name))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &amp;&amp; (sex == o.sex || sex.equals(o.sex))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &amp;&amp; (weight == o.weight || weight.equals(o.weight))<BR>&nbsp;&nbsp;&nbsp; ;<BR>&nbsp;&nbsp;&nbsp; return result;<BR>&nbsp; }<BR>&nbsp; }<BR>到此已经完成了该做的事了，下面是一个使用的例子。</FONT></P>
<P><FONT style="BACKGROUND-COLOR: #d3d3d3" face=宋体 color=#0000ff size=4>l查询方式：<BR>例子：<BR>Void testQuery() throws Exception{<BR>&nbsp;&nbsp;&nbsp; {<BR>System.setProperty(Const.RUN_KEY, Const.POOL_FACTORY_KEY);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.setProperty(Const.CONFIG_PATH,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "E:/project/CEAConnection/pool-config.xml");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.setProperty(Const.REPOSITORY_CONFIG_PATH,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "E:/project/CEAConnection/repository.xml");<BR>}</FONT></P>
<P><FONT style="BACKGROUND-COLOR: #d3d3d3" face=宋体 color=#0000ff size=4>ConnectionManage connectionManage = new ConnectionManage();<BR>&nbsp;connectionManage.activity("com.cea.boat.dao.Cat cat");<BR>&nbsp;&nbsp; <BR>&nbsp;&nbsp; Query Query=connectionManage.createQuery(“cat. Catid=’1’ ”);<BR>&nbsp;&nbsp;&nbsp; while (Query.hasNext()) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Object[] objects = Query.next();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Cat cat = (Cat) objects[0];<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp;connectionManage.close();<BR>}<BR>说明：<BR>在WEB中使用只需要在网站启动时声明一次即可。<BR>{<BR>//指明使用连接池<BR>System.setProperty(Const.RUN_KEY, Const.POOL_FACTORY_KEY);<BR>//连接池参数配置文件<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.setProperty(Const.CONFIG_PATH,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "E:/project/CEAConnection/pool-config.xml");<BR>//配置文件指定<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.setProperty(Const.REPOSITORY_CONFIG_PATH,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "E:/project/CEAConnection/repository.xml");<BR>}</FONT></P>
<P><FONT style="BACKGROUND-COLOR: #d3d3d3" face=宋体 color=#0000ff size=4>&nbsp;&nbsp; 声明一个连接管理者，管理数据库资源，事务的起始，它的生命周期最好是在一个事务结束就完结，当然你也可以在这个事务完结时继续用这个实例，来创建下一个事务的开始。不建议如此使用。<BR>&nbsp;&nbsp;&nbsp; ConnectionManage DataManage = new ConnectionManage();<BR>&nbsp;&nbsp;&nbsp; <BR>激活要使用类（在配置中必须有Cat）,类名为全路径如果要使用多个对象，则对象间要用逗号相隔开<BR>connectionManage.activity("com.cea.boat.dao.Cat cat");</FONT></P>
<P><FONT style="BACKGROUND-COLOR: #d3d3d3" face=宋体 color=#0000ff size=4>这里只需要给出SQL查询条件比如SQL中是select * from cat cat where cat.Catid=‘1’那么 select * from cat cat where 这里后台已经帮你完成，你需要做的就是把条件完成，如果没有条件则为空.<BR>Query Query = connectionManage.createQuery(“cat. Catid=’1’ ”);</FONT></P>
<P><BR><FONT style="BACKGROUND-COLOR: #d3d3d3" face=宋体 color=#0000ff size=4>&nbsp;&nbsp; Query.hasNext()的作用相当于resultset.next()查看是否还存在记录，Query.next()返回一个对象数组这里如果activity的是多个对象，那么objects里会顺序的存储相应的对象实例，使用的时候强制转化就可以了。<BR>while (Query.hasNext()) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Object[] objects = Query.next();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Cat cat = (Cat) objects[0];<BR>&nbsp; }</FONT></P>
<P><FONT style="BACKGROUND-COLOR: #d3d3d3" face=宋体 color=#0000ff size=4>使用完毕，释放使用的数据库资源<BR>&nbsp;connectionManage.close();</FONT></P>
<P><FONT style="BACKGROUND-COLOR: #d3d3d3" face=宋体 color=#0000ff size=4>l新增方式：<BR>&nbsp; 由于没有主键自动生成，因此主键暂时只能由自己来维护，要保证catid为111的在表里不存在，否则会出现异常。<BR>Void testInsert() throws Exception{<BR>Cat cat = new Cat();<BR>cat. setCatId(“111”);<BR>&nbsp;&nbsp;&nbsp; cat. SetSex(“F”);<BR>&nbsp;&nbsp;&nbsp; cat. setName(“catm”);<BR>&nbsp;&nbsp;&nbsp; ConnectionManage cm = new ConnectionManage();<BR>&nbsp;&nbsp;&nbsp; cm.create(cat);<BR>&nbsp;&nbsp;&nbsp; cm.commit();<BR>cm.close();<BR>}</FONT></P>
<P><FONT style="BACKGROUND-COLOR: #d3d3d3" face=宋体 color=#0000ff size=4>l更新方式：<BR>表里已经存在catid为111的猫，否则查不到这条记录就更新不了信息<BR>Void testUpdate() throws Exception{<BR>Cat cat = new Cat();<BR>cat. setCatId(“111”);<BR>&nbsp;&nbsp;&nbsp; cat. SetSex(“F”);<BR>&nbsp;&nbsp;&nbsp; cat. setName(“catmm”);<BR>&nbsp;&nbsp;&nbsp; ConnectionManage cm = new ConnectionManage();<BR>&nbsp;&nbsp;&nbsp; cm.update(cat);<BR>&nbsp;&nbsp;&nbsp; cm.commit();<BR>cm.close();<BR>}</FONT></P>
<P><FONT style="BACKGROUND-COLOR: #d3d3d3" face=宋体 color=#0000ff size=4>l删除方式：<BR>删除方式比较简单，只要给出对象，并且主键值不为空，就可以删除表中记录。<BR>Void testDelete() throws Exception{<BR>Cat cat = new Cat();<BR>cat. setCatId(“111”);<BR>&nbsp;&nbsp;&nbsp; ConnectionManage cm = new ConnectionManage();<BR>&nbsp;&nbsp;&nbsp; cm.delete(cat);<BR>&nbsp;&nbsp;&nbsp; cm.commit();<BR>cm.close();<BR>}<BR></FONT></P><img src ="http://www.blogjava.net/cyicecream/aggbug/13129.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/cyicecream/" target="_blank">ceaboat</a> 2005-09-15 23:41 <a href="http://www.blogjava.net/cyicecream/archive/2005/09/15/13129.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>