JSP and MySQL Problem
I have all my files in a war file:
ROOT.war:
->WEB-INF
->lib
->jstl.jar
->standard.jar
->org (the driver folder)
When the server runs the jsp file I get:
javax.servlet.ServletException: Unable to get connection, DataSource invalid: "java.sql.SQLException: No suitable driver"
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:848)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:781)
org.apache.jsp.index_jsp._jspService(org.apache.jsp.index_jsp:103)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
Is there a solution to this?
Thanks in advace!
[nobr]My jsp file:
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%>
<html>
<body>
<c:out value="${param.name}"/>
<sql:setDataSource var="db" driver="com.mysql.jdbc.Driver" url="jdbc:mysql:localhost" user="sir?wojciech" password="tusamaliti"/>
<c:set var='s'value="${param.area1}"/>
<c:out value="${s}"/><br>
<sql:query var="query1" dataSource="${db}" sql="${s}" />
<table border="1">
<c:forEach var="row" items="${query1.rows}">
<tr>
<td><c:out value="${row.name}"/></td>
<td><c:out value="${row.place}"/></td>
</tr>
</c:forEach>
</table>
</body>
</html>
[/nobr]
Ok there are two reasons this error message could occur
1 - you have misspelled the driver name (looks ok)
2 - the driver is not in the classpath.
You say it is in the org folder. That is under classes? Do you have the class files for your driver?
The standard way to include the driver is to put the mysql jar file into the web-inf/lib directory.
Alternatively, you set up a JNDI datasource and use that rather than configure it on the fly in a JSP page.
With tomcat, put the driver jar file in the [TOMCAT]/common/lib directory and then configure as shown here: http://tomcat.apache.org/tomcat-5.0-doc/jndi-datasource-examples-howto.html
You should not have a web app named ROOT, IMO.
Looks like you extracted the contents of the MySQL JDBC JAR. That's a big error. Put that JAR in the WEB-INF/lib directory where all the others go.
Directories with .class files in them go in WEB-INF/classes.
Sounds like you've got a lot to learn about how to deploy Web apps properly.
%