1 Reply Latest reply on Apr 1, 2005 5:46 AM by Mikkel Heisterberg

    Unable to get connection, DataSource invalid: "java.sql.SQLE

    Vicente Torrejon Newbie

      Hi there! I have a J2EE application, using CMP beans, and a SQL Server DDBB. I've had no problems developing CMP beans for 1 month with my DDBB, but now I'm using jstl, and I can not access the DDBB.

      I have the next message:

      Unable to get connection, DataSource invalid: "java.sql.SQLException: No suitable driver"

      And my code is:

      <sql:query var="user_balance" dataSource="java:/MSSQLDS">
      SELECT top 1 status_date, start_bal, end_bal, (select max (status_date) from ReportUserDaily) as 'max_date' FROM ReportUserDaily

      java:/MSSQLDS is the JNDI name of the DDBB, giving no problems with CMP beans, and properly defined(I think) in JBOSS. Do I need to duplicate the definitions for Tomcat???!!

      jlst tld are properly defined, as I've noticed it corrects me when I don't follow the right syntax.

      I'm lost. Any suggestions????

      Thanks everybody for read that.

        • 1. Re: Unable to get connection, DataSource invalid:
          Mikkel Heisterberg Newbie

          I had the same problem today but found the answer in the DataSourceUtil class of the Jakarta implementation of JSTL. The problem is that the SQL function looks for the DataSource in the "java:comp/env" namespace where as your datasource probably is in the "java:" namespace. Mine was anyways.

          The solution is to map the datasource to Tomcat using the web.xml and jboss-web.xml deployment descriptors:


           <!-- JDBC DataSources (java:comp/env/jdbc) -->
           <description>The used datasource</description>

           <!-- make sure the web container can get jdbc connections -->

          The above makes the java:/pestikom2 from JBoss datasource available in the java:/comp/env namespace in Tomcat. The datasource can now be referenced from JSTL using:
          <sql:query dataSource="jdbc/DefaultDS" var="some_var" scope="page" sql="select * from foo">