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!

[1115 byte] By [sir_wojciecha] at [2007-10-2 8:32:48]
# 1

[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]

sir_wojciecha at 2007-7-16 22:33:59 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

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

evnafetsa at 2007-7-16 22:33:59 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
Thanks for the reply.The driver name is correct (at least I think so) and I've tried both the classes in a jar and out of it in a folder.
sir_wojciecha at 2007-7-16 22:33:59 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
Both of course in the web-inf/lib folder...Any solution?
sir_wojciecha at 2007-7-16 22:33:59 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5
ok I've solved one thing but the error is the samethe folder should be com not org
sir_wojciecha at 2007-7-16 22:33:59 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6
ok I've solved one thing but the error is the samethe folder should be com not orgHere's the link to the file: http://www.freefileupload.net/file.php?file=files/271205/1135721509/ROOT.zip
sir_wojciecha at 2007-7-16 22:33:59 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 7

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.

%

duffymoa at 2007-7-16 22:33:59 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...