In case you configure a JNDI lookup for the database connection,and pass a string as a parameter to the dataSource attribute of either sql:setDataSource or sql:query an exception: javax.servlet.jsp.JspException: Unable to get connection, DataSource invalid is thrown. The configuration is done as follows: in server.xml of tomcat ======================================================================= <Resource name="jdbc/ActivityDB" auth="Container" description="Database for ActivtyTracking" type="javax.sql.DataSource"/> <ResourceParams name="jdbc/ActivityDB"> <parameter> <name>user</name> <value>PBPUBLIC</value> </parameter> <parameter> <name>password</name> <value>PBPUBLIC</value> </parameter> <parameter> <name>driverClassName</name> <value>com.pointbase.jdbc.jdbcUniversalDriver</value> </parameter> <parameter> <name>driverName</name> <value>jdbc:pointbase:server://localhost/ActivityDB</value> </parameter> </ResourceParams> ========================================================================= in the web.xml ========================================================================= <resource-ref> <res-ref-name>jdbc/ActivityDB</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> <res-sharing-scope>Shareable</res-sharing-scope> </resource-ref> ==================================================================== the JSP looks like this: =================================================================== <sql:query var="person" dataSource="jdbc/ActivityDB" scope ="session"> select user_mast.f_name , project_mast.proj_name,task_mast.task_name, task_mast.status as task_status, activity_mast.act_name, activity_mast.status as activity_status from user_mast, activity_mast, task_mast, project_mast where user_mast.user_ID = activity_mast.resp_engineer and task_mast.task_ID = activity_mast.parent_task and task_mast.project = project_mast.proj_ID and activity_mast.act_st_dt > ? and activity_mast.act_end_dt < ? <sql:param value="${from}" /> <sql:param value="${to}" /> </sql:query> ===================================================================
This works for me. Did you add the JNDI resource mapping in your server.xml (shown below) to the <Context> element of the specific application that tries to access the JNDI resource? Note that instead of modifying your server.xml, you may create a <webapp>.xml file (where you replace <webapp> with your webapp's name) in your server's webapps directory, and add the JNDI resource mapping to it. In my case, I created a standard-examples.xml file with these contents: <Context path="/standard-examples" docBase="standard-examples" debug="0"> <Resource name="jdbc/BookDB" reloadable="true" auth="Container" type="javax.sql.DataSource"/> <ResourceParams name="jdbc/BookDB"> <parameter> <name>user</name> <value>PBPUBLIC</value> </parameter> <parameter> <name>password</name> <value>PBPUBLIC</value> </parameter> <parameter> <name>driverClassName</name> <value>com.pointbase.jdbc.jdbcUniversalDriver</value> </parameter> <parameter> <name>driverName</name> <value>jdbc:pointbase:server://localhost/sample</value> </parameter> </ResourceParams> </Context>