Meaningless Drivel is fun!*
The moose likes Struts and the fly likes Error: Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Frameworks » Struts
Reply locked New topic
Author

Error: "No suitable driver"

Marcos Gomes
Greenhorn

Joined: Jul 02, 2007
Posts: 6
Hello friends,

I'm trying to connect a DB in my application as follows:

------------------------------------------------------------
<sql:setDataSource var="db" url="jdbc:mysql://localhost/tpsg"
driver="com.mysql.jdbc.Driver" user="root" password="password"/>

<sql:transaction dataSource="db">

<sql:query var="menus">
SELECT * FROM menu_item order by id;
</sql:query>

</sql:transaction>
-------------------------------------------------------------

But Tomcat shows me the following error message:

javax.servlet.jsp.JspTagException: Error getting connection: "No suitable driver"
org.apache.taglibs.standard.tag.common.sql.TransactionTagSupport.doStartTag(TransactionTagSupport.java:115)
org.apache.taglibs.standard.tag.el.sql.TransactionTag.doStartTag(TransactionTag.java:57)
org.apache.jsp.menu_jsp._jspx_meth_sql_005ftransaction_005f0(menu_jsp.java:173)
org.apache.jsp.menu_jsp._jspService(menu_jsp.java:111)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.struts.chain.commands.servlet.PerformForward.handleAsForward(PerformForward.java:113)
org.apache.struts.chain.commands.servlet.PerformForward.perform(PerformForward.java:96)
org.apache.struts.chain.commands.AbstractPerformForward.execute(AbstractPerformForward.java:54)
org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304)
org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
-----------------------------------------------------------------

This is very intersting because when I use the same configuration with Hibernate, it works well:

<!-- mysql configuration -->
<property name="connection.url">jdbc:mysql://localhost/tpsg</property>
<property name="connection.username">root</property>
<property name="connection.password">password</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
--------------------------------------------------------
And when I use another DB as bellow, it works as well:

<sql:setDataSource var="db" url="jdbc:hsqldb b/menu"
driver="org.hsqldb.jdbcDriver" user="sa" password=""/>

<sql:transaction dataSource="db">

<sql:query var="menus">
SELECT * FROM menu_item order by id;
</sql:query>

</sql:transaction>
----------------------------------------------------------

Please, anyone has any idea why this happens ??

Thank you.

[]'s
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42357
    
  64
Please do not post the same question to multiple forums: CarefullyChooseOneForum

Let's continue the discussion in this duplicate thread.


Ping & DNS - my free Android networking tools app
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error: "No suitable driver"