Campano, Troy wrote:
Can JSTL work without a DataSource?
Is there a way just to pass it the connection ?
You can not pass a Connection to the JSTL actions (since that causes
potential Connection management issues), but you can create a simple,
non-pooled DataSource for any regular JDBC driver using one of these
approaches:

  <sql:setDataSource var="myDataSource"
    url="jdbc:myJDBCDriverSpecificURL"
    driver="com.somecompany.JDBCDriverClassName"
    user="myDBUser"
    password="myDBPassword" />

  <sql:query dataSource="myDataSource" ... />

or

  in web.xml
  <web-app>
    ...
    <context-param>
      <param-name>
        javax.servlet.jsp.jstl.sql.dataSource
      </param-name>
      <param-value>

jdbc:myJDBCDriverSpecificURL,com.somecompany.JDBCDriverClassName,myDBUser,myDBPassword
      </param-value>
    </context-param>

  in JSP file:
    <sql:query ... />

The second alternative makes the DataSource the default DataSource, so
you don't have to specify it at all in the JSTL SQL action elements.
You get the same effect for the first alternative if you omit the "var"
attribute.

Hans
--
Hans Bergsten           [EMAIL PROTECTED]
Gefion Software         http://www.gefionsoftware.com
JavaServer Pages        http://TheJSPBook.com

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

http://archives.java.sun.com/jsp-interest.html
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.jsp
http://www.jguru.com/faq/index.jsp
http://www.jspinsider.com

Reply via email to