aspose file tools*
The moose likes JSP and the fly likes java.sql.SQLException: No suitable driver found Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "java.sql.SQLException: No suitable driver found" Watch "java.sql.SQLException: No suitable driver found" New topic
Author

java.sql.SQLException: No suitable driver found

Harish Moolchandani
Greenhorn

Joined: Mar 12, 2010
Posts: 23
Hello friends, I'm having a problem using Oracle Type4 driver.
I had the following code:

<%@taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%>
<%@page errorPage="/errorpage.jsp"%>

<sql:setDataSource url="jdbc:oracle:thin:@localhost:1521:orcl" driver="oracle.jdbc.OracleDriver" user="gameshop" password="gameshop" var="database" />

<sql:update sql="insert into ORDER_SUBMITTED values(ORDER_SUBMITTED_SEQ.nextval, ?, SYSDATE)" dataSource="${database}" var="order_submitted">
<sql:param value="${userinfo.user_id}"/>
</sql:update>


running this produces following error:
Unable to get connection, DataSource invalid: "java.sql.SQLException: No suitable driver found for ${database}"

I've tried these things:
1. The driver requires "ojdbc14.jar" file so I put it in both the lib(i.e in WEB-INF/lib and Tomcat/lib) but nothing solved the problem.
2. I have tried using it on both Tomcat 5.5 and Tomcat 6 but the problem still remains same.
3. I also tried to use the driver "oracle.jdbc.driver.OracleDriver" instead of "oracle.jdbc.OracleDriver" but no improvement.
4. The classpaths for ojdbc14.jar file is also set in Environment variable. One java desktop application is running fine with this driver, but I'm using it first time with JSP's JSTL.


Please help......It's been one day I'm stuck with this problem
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61755
    
  67

Two things:

  • The JSTL SQL tags are for quick prototyping and should not be used in production code.
  • The error message that you are getting indicates to me that the EL is not being properly evaluated on your page. What happens when you put ${3+4} on your page? Do you see 7?


  • [Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
    Aman Goel
    Greenhorn

    Joined: Jan 14, 2010
    Posts: 15
    Have you put classes12.jar in tomcat library
    eid hazim
    Greenhorn

    Joined: Jul 24, 2011
    Posts: 6
    Dears,
    i face same this problem ,and the solution ware as the following:

    1- write xml file which contains the JDBC Connection attributes:
    note: the file name should be same webapplication name, and it's case sensitive.

    XML file : Test.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <Context antiJARLocking="true" path="/Test">
    <Resource name="jdbc/TestDB" auth="Container"
    type="javax.sql.DataSource" driverClassName="oracle.jdbc.OracleDriver"
    url="jdbcracle:thin:@localhost:1521:testdb"
    username="user123" password="password123" maxActive="20" maxIdle="10"
    maxWait="-1"/>
    </Context>

    2- put the file name in the \Tomcat 6.0\conf\Catalina\localhost directory.
    3- add the following tags in the web.xml:
    <resource-ref>
    <description>Oracle Datasource example</description>
    <res-ref-name>jdbc/TestDB</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    </resource-ref>
    4- use the lookup method to get the DataSource as :
    DataSource ds = (DataSource)new InitialContext().lookup( "java:comp/env/jdbc/TestDB" );

    note: the names are case sensitive

    Regards.
    Aditya Kumar Shrivastava
    Greenhorn

    Joined: Apr 15, 2011
    Posts: 1
    Hi,

    Found the solution.

    The Database drivers must be copied within the: <your_glassfish_domain>/lib/ext folder, NOT just /lib folder (Don't forget the "ext" directory). This worked for me too.

    This is true in all Glassfish versions.

    HTH Eddie Kumar
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: java.sql.SQLException: No suitable driver found