I have a web app, deployed to
JBoss and I'm trying to configure a data source. The latest error I'm getting, on attempting to access a page is:
Unable to get connection, DataSource invalid: "java.sql.SQLException: No suitable driver"
The web app is deployed to the 'smt' context:
Here's my code:
smt-ds.xml:
<datasources>
<local-tx-datasource>
<jndi-name>jdbc/smt</jndi-name>
<connection-url>
jdbc:mysql://localhost:3306/smt</connection-url>
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<user-name>smt</user-name>
<password>pass</password>
<metadata>
<type-mapping>MySQL</type-mapping>
</metadata>
<new-connection-sql>select count(*) from quote_of_the_day</new-connection-sql>
<check-valid-connection-sql>select count(*) from quote_of_the_day</check-valid-connection-sql>
</local-tx-datasource>
</datasources>
web.xml (relevant part anyway):
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <display-name>smt</display-name>
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/smt</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<serv...
jboss-web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jboss-web PUBLIC "-//JBoss//DTD Web Application 2.3//EN"
"http://www.jboss.org/j2ee/dtd/jboss-web_3_0.dtd">
<jboss-web>
<resource-ref>
<res-ref-name>jdbc/smt</res-ref-name>
<jndi-name>
java:jdbc/mysql</jndi-name>
</resource-ref>
</jboss-web>
qotd.jsp (excerpt):
<sql:query var="rs" dataSource="jdbc/smt">
select quote, submitted_by, author, date_submitted
from quote_of_the_day
where id = ?
<sql
aram value="${maxid.rows[0].id}" />
</sql:query>
<TABLE class="body">
<TR>
<TD align="center" class="area_title" colspan="2">Change the Quote of the Day</TD>
</TR>
<TR>
<TD colspan="2" align="center" class="alert">${param.message}</TD>
</TR>
<tr><td height="5"><!-- spacer --></td></tr>
<tr>
<td class="label" valign="top">Quote:</td>
<td>
<TEXTAREA name="new_quote" cols="30" rows="5">${rs.rows[0].quote}</TEXTAREA>
</td>
</tr>...
It deploys clean, with no errors about trying to reference any jndi or whatever. I can access other parts of the web app where there's no need for a database connection. But, if I try this page, 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.qotd_jsp._jspService(org.apache.jsp.qotd_jsp:135)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
root cause
javax.servlet.jsp.JspException: Unable to get connection, DataSource invalid: "java.sql.SQLException: No suitable driver"
org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.getConnection(QueryTagSupport.java:276)
org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.doStartTag(QueryTagSupport.java:159)
org.apache.jsp.qotd_jsp._jspx_meth_sql_query_0(org.apache.jsp.qotd_jsp:268)
org.apache.jsp.qotd_jsp._jspx_meth_c_when_0(org.apache.jsp.qotd_jsp:189)
org.apache.jsp.qotd_jsp._jspx_meth_c_choose_0(org.apache.jsp.qotd_jsp:156)
org.apache.jsp.qotd_jsp._jspService(org.apache.jsp.qotd_jsp:117)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.9 logs.