Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java.sql.SQLException: No suitable driver found

 
Harish Moolchandani
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64851
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?

  •  
    Aman Goel
    Greenhorn
    Posts: 15
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Have you put classes12.jar in tomcat library
     
    eid hazim
    Greenhorn
    Posts: 6
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Posts: 1
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic