This content has been marked as final.
Show 1 reply
-
1. Re: Unable to get connection, DataSource invalid:
lekkim Apr 1, 2005 5:46 AM (in response to vtorrejon)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:
web.xml<!-- JDBC DataSources (java:comp/env/jdbc) --> <resource-ref> <description>The used datasource</description> <res-ref-name>jdbc/DefaultDS</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref>
jboss-web.xml<!-- make sure the web container can get jdbc connections --> <resource-ref> <res-ref-name>jdbc/DefaultDS</res-ref-name> <res-type>javax.sql.DataSource</res-type> <jndi-name>java:/pestikom2</jndi-name> </resource-ref>
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"> </sql:query>