4 Replies Latest reply on Nov 23, 2008 3:23 AM by dvohra21

    JSTL: Error with <sql:setDataSource dataSource="xxx" />


      I'm trying to create a connection to an Oracle database from a DataSource defined in my weblogic console under the JNDI name "jdbc/xxx_cp".

      I use Weblogic 9, connecting to an Oracle 9.2 database.

      So I included the file "jdbc/lib/classes12.jar" (from the oracle installation) under the name "/WEB-INF/lib/classes12.jar" in my .war file.

      I call the DataSource from the following JSTL command:


      I get this error:

      <Oct 22, 2008 10:02:38 AM CEST> <Error> <HTTP> <BEA-101017> <[weblogic.servlet.internal.WebAppServletContext@a089d4 - appName: 'xxx.war', name: 'xxx.war', context-path: '/xxx'] Root cause of ServletException.
      javax.servlet.jsp.JspException: Unable to get connection, DataSource invalid: "java.sql.SQLException: No suitable driver"
      at org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.getConnection(QueryTagSupport.java:276)
      at org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.doStartTag(QueryTagSupport.java:159)
      at jsp_servlet.__page._jsp__tag3(__page.java:311)
      at jsp_servlet.__page._jsp__tag0(__page.java:195)
      at jsp_servlet.__page._jspService(__page.java:152)
      Truncated. see log file for complete stacktrace

      However this works:

      Does anyone know how to solve this, so I don't need to use the second code snippet?

      Thank you,

        • 1. Re: JSTL: Error with <sql:setDataSource dataSource="xxx" />
          Olaf Heimburger-Oracle
          A datasource is usually configured on server level. Your inclusion of the driver doesn't matter as long you haven't set up the necessary configuration files.

          Your second example works because you don't use server level configuration.

          1 person found this helpful
          • 2. Re: JSTL: Error with <sql:setDataSource dataSource="xxx" />
            Username and Password are required to be set if driver and url are specified.
            <sql:setDataSource driver="oracle.jdbc.OracleDriver" url="jdbc:oracle:thin:@localhost:1521:ORCL" user="OE" password="pw"/>

            If the dataSource attribute is used, username and password are not required.

            Create a datasource JNDI. Also specify a resource-ref tag in the web.xml.
            • 3. Re: JSTL: Error with <sql:setDataSource dataSource="xxx" />
              Hi Dvohra,

              Indeed, you are right, I didn't know that I needed to modify the web.xml, neither did any of my colleague, since we just started creating small web tools with JSTL (and JSP). This fixed everything and I'm now fully able to use a DataSource defined in the WL console.

              I removed the driver from my example also.

              Thank you,

              • 4. Re: JSTL: Error with <sql:setDataSource dataSource="xxx" />
                The resource-ref in the web.xml is not required for the JSTL SQL tag library. The resource-ref in web.xml for the datasource JNDI is required if the datasource JNDI lookup is used in a JSP/Servlet web application with InitialContext.