Hi. I am using the netbeans e-commerce tutorial to learn about web development. I am using
tomcat instead of glassfish and I've been trying to establish a connection pool with tomcat and MySQL but have not been successful. I've spent hours looking at forums and tutorials but to no avail.
My context.xml code:
<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/OnlineStore">
<resource-ref>
<description>Connection pool to mysql onlinestore database</description>
<res-ref-name>onlinestore</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
</Context>
My web.xml includes the following code:
<resource-ref>
<description>Connection pool to mysql onlinestore database</description>
<res-ref-name>onlinestore</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
My
test file testDataSource.jsp code:
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>
JSP Page</title>
</head>
<body>
<h1>Hello World!</h1>
<sql:query var="result" dataSource="onlinestore">
SELECT * FROM category
</sql:query>
</body>
</html>
Also, I've imported the JSTL 1.1 libraries and the MySQL-connector-java-5.1.18-bin.jar.
I am getting the following error:
HTTP Status 500 - An exception occurred processing JSP page /test/testDataSource.jsp at line 20
--------------------------------------------------------------------------------
type Exception report
message An exception occurred processing JSP page /test/testDataSource.jsp at line 20
description The server encountered an internal error that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: An exception occurred processing JSP page /test/testDataSource.jsp at line 20
17: </head>
18: <body>
19: <h1>Hello World!</h1>
20: <sql:query var="result" dataSource="onlinestore">
21: SELECT * FROM category
22: </sql:query>
23:
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:568)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:455)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
root cause
javax.servlet.ServletException: javax.servlet.jsp.JspException: Unable to get connection, DataSource invalid: "org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create
JDBC driver of class '' for connect URL 'null'"
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:912)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:841)
org.apache.jsp.test.testDataSource_jsp._jspService(testDataSource_jsp.java:94)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
root cause
javax.servlet.jsp.JspException: Unable to get connection, DataSource invalid: "org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'"
org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.getConnection(QueryTagSupport.java:285)
org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.doStartTag(QueryTagSupport.java:168)
org.apache.jsp.test.testDataSource_jsp._jspx_meth_sql_005fquery_005f0(testDataSource_jsp.java:116)
org.apache.jsp.test.testDataSource_jsp._jspService(testDataSource_jsp.java:82)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
Is there anyone out there who can help me or point me in the right direction? It would be very, very much appreciated.