tomcat6连接池问题
操作系统winXP
tomcat版本6.0.18
mysql版本5.0.22
jdbc:mysql-connector-java-5.0.4-bin.jar 已经放入tomcat6\lib下
tomcat contex.xml
<Ressource name="jdbc/bbs" auth="Container"
type="javax.sql.DataSource"
maxActive="100"
maxIdle="30"
maxWait="10000"
username="root"
password="dell"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/bbs"
/>
web.xml定义
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/bbs</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
jsp测试
<%
out.println("测试开始");
out.print("<br>");
DataSource ds=null;
Connection conn=null;
try
{
InitialContext ctx = new InitialContext();
ds = (DataSource)ctx.lookup("java:comp/env/jdbc/bbs");
conn = ds.getConnection();
Statement stmt = conn.createStatement();
//这里的数据库前文提及的Data Source URL配置里包含的数据库。
String strSql = "select * from bbs";
ResultSet rs = stmt.executeQuery(strSql);
while(rs.next())
{
out.println("标题:" + rs.getString("title"));
}
out.print("测试结束");
conn.close();
}
catch(Exception ex)
{
out.print("出现例外,信息是:"+ex.getMessage());
ex.printStackTrace();
}
%>
jsp页面exception报错:
Cannot create JDBC driver of class '' for connect URL 'null'
tomcat后台报错:
org.apache.tomcat.dbcp.dbcp.
SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1150)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)
at org.apache.jsp.testdb_jsp._jspService(testdb_jsp.java:73)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)