• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

JBoss JSTL Datasource issue

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JBoss version: jboss-4.2.1.GA

Hello,
I have configured my Oracle datasource successfully and it works but when I extract data using Connection Pool. But when I try to use the same datasource for a JSTL <sql:setDataSource> tag, I get the following error:

org.apache.jasper.JasperException: An exception occurred processing JSP page /showAirCrafts.jsp at line 9

7: <sql:setDataSource var="ds" dataSource="java:/jdbc/oracleDS"/>
8:
9: <sql:query dataSource="${ds}" var="date" sql="SELECT sysdate FROM DUAL"/>

Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:518)
...

root cause

javax.servlet.ServletException: javax.servlet.jsp.JspException: Unable to get connection, DataSource invalid: "No suitable driver"


*************** oracle-ds.xml ************

<local-tx-datasource>
<jndi-name>jdbc/oracleDS</jndi-name>
<connection-url>
jdbcracle:thin:@xxx.xxx.xx.xxx:1521:f35test
</connection-url>
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
<user-name>xxxxxx</user-name>
xxxxxxx
...
</local-tx-datasource>

************************************

***********DBConnection.java******(THIS WORKS)
...
javax.sql.DataSource ds = (javax.sql.DataSource) initialContext
.lookup("java:comp/env/jdbc/oracleDS");
...
************************************

*******************jboss-web.xml*********
...
<resource-ref>
<res-ref-name>jdbc/pmaDS</res-ref-name>
<jndi-name>java:/jdbc/pmaDS</jndi-name>
</resource-ref>
...
***************************************

****************web.xml*****************
...
<resource-ref>
Oracle Connection
<res-ref-name>jdbc/oracleDS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
...
************************************

**************JSP (THIS DOESN'T WORK)*****
<%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>
...
<sql:setDataSource var="ds" dataSource="java:/jdbc/oracleDS"/>

<sql:query dataSource="${ds}" var="date" sql="SELECT sysdate FROM DUAL"/>
...
*****************************************


I am new to JSTL. Any help would be appreciated.

Thank you
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

root cause

javax.servlet.ServletException: javax.servlet.jsp.JspException: Unable to get connection, DataSource invalid: "No suitable driver"



Can you post the entire exception stacktrace? Also, where have you placed the jar file containing the database driver?
 
MK Shikarpuri
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Got it working. Had to remove the "var" variable from the <sql:setDatasource> tag

<sql:setDataSource dataSource="java:/jdbc/oracleDS"/>
 
I'm still in control here. LOOK at this tiny ad!
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic