配置Web.xml使这个Servlet在启动时加载。<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
<servlet>
<servlet-name>testConnectionPooler</servlet-name>
<servlet-class>com.test.web.TestServlet</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
启动Tomcat
<?xml:namespace prefix = v ns = "urn:schemas-microsoft-com:vml" /><shapetype id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"><stroke joinstyle="miter"></stroke><formulas><f eqn="if lineDrawn pixelLineWidth 0"></f><f eqn="sum @0 1 0"></f><f eqn="sum 0 0 @1"></f><f eqn="prod @2 1 2"></f><f eqn="prod @3 21600 pixelWidth"></f><f eqn="prod @3 21600 pixelHeight"></f><f eqn="sum @0 0 1"></f><f eqn="prod @6 1 2"></f><f eqn="prod @7 21600 pixelWidth"></f><f eqn="sum @8 21600 0"></f><f eqn="prod @7 21600 pixelHeight"></f><f eqn="sum @10 21600 0"></f></formulas><path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"></path><lock v:ext="edit" aspectratio="t"></lock></shapetype><shape id="_x0000_i1025" style="WIDTH: 129.75pt; HEIGHT: 85.5pt" type="#_x0000_t75"><img src="http://dev.csdn.net/Develop/ArticleImages/25/25884/CSDN_Dev_Image_2004-3-211047340.png" o=""></shape>
出现信息如下
2004-3-20 <?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" /><time hour="21" minute="28"><span lang="EN" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: red; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体; mso-highlight: white">21:28:05</span></time> org.apache.commons.modeler.Registry getRegistry
信息: Creating new Registry instance
2004-3-20 <time hour="21" minute="28"><span lang="EN" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: red; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体; mso-highlight: white">21:28:06</span></time> org.apache.commons.modeler.Registry getServer
信息: Creating MBeanServer
2004-3-20 <time hour="21" minute="28"><span lang="EN" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: red; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体; mso-highlight: white">21:28:07</span></time> org.apache.coyote.http11.Http11Protocol init
信息: Initializing Coyote HTTP/1.1 on port 80
Starting service Tomcat-Standalone
Apache Tomcat/4.1.27-LE-jdk14
2004-03-20 21:28:11,843 INFO [main] web.TestServlet (TestServlet.java:43) - 连接池OK
2004-3-20 <time hour="21" minute="28"><span lang="EN" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: red; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体; mso-highlight: white">21:28:13</span></time> org.apache.struts.util.PropertyMessageResources <init>
信息: Initializing, config='org.apache.struts.util.LocalStrings', returnNull=true
2004-3-20 <time hour="21" minute="28"><span lang="EN" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: red; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体; mso-highlight: white">21:28:13</span></time> org.apache.struts.util.PropertyMessageResources <init>
现在我们关闭MySQL数据库服务,再重新启动Tomcat
出现信息如下
2004-3-20 <time hour="21" minute="26"><span lang="EN" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: red; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体; mso-highlight: white">21:26:48</span></time> org.apache.commons.modeler.Registry getRegistry
信息: Creating new Registry instance
2004-3-20 <time hour="21" minute="26"><span lang="EN" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: red; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体; mso-highlight: white">21:26:49</span></time> org.apache.commons.modeler.Registry getServer
信息: Creating MBeanServer
2004-3-20 <time hour="21" minute="26"><span lang="EN" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: red; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体; mso-highlight: white">21:26:50</span></time> org.apache.coyote.http11.Http11Protocol init
信息: Initializing Coyote HTTP/1.1 on port 80
Starting service Tomcat-Standalone
Apache Tomcat/4.1.27-LE-jdk14
2004-03-20 21:26:55,421 ERROR [main] web.TestServlet (TestServlet.java:48) - 出现错误Cannot create PoolableConnectionFactory
2004-3-20 <time hour="21" minute="26"><span lang="EN" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: red; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体; mso-highlight: white">21:26:56</span></time> org.apache.struts.util.PropertyMessageResources <init>
信息: Initializing, config='org.apache.struts.util.LocalStrings', returnNull=true
2004-3-20 <time hour="21" minute="26"><span lang="EN" style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: red; FONT-FAMILY: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体; mso-highlight: white">21:26:56</span></time> org.apache.struts.util.PropertyMessageResources <init>
好了数据库连接已经成功,接下来我们重新配置Hibernate,使其支持连接池