You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-user@tomcat.apache.org by aps olute <ap...@yahoo.com> on 2003/03/25 22:26:43 UTC

What is the default datasource?

Hi,
  What is the default datasource used if one uses <sql:query>,
<sql:update> and <sql:transaction> without the dataSource attribute? or
no <sql:dataSource ... />

  How about if one has this on the top of jsp page:
 5 <%@ page import="javax.servlet.jsp.jstl.core.Config" %>
 6  <%
Config.set(session,"javax.servlet.jsp.jstl.sql.dataSource","jdbc:mys
ql://192.168.100.1:3306/menagerie,com.mysql.jdbc.Driver,mysql"); %>
 7 <%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql" %>  
I didnt have user and password setup on the above, is the dataSource
set-up properly? and how does the sql tags refers to this dataSource?
   I am using tomcat 4.1.18 + jdk1.4.0_01. Someone has configuration to
setup the datasource correctly with tomcat? I always had this issue and
was never ever able to resolve tomcat datasource issue.

Thanks in advance.
aps

__________________________________________________
Do you Yahoo!?
Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop!
http://platinum.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: What is the default datasource?

Posted by Henri Yandell <ba...@generationjava.com>.


On Tue, 25 Mar 2003, aps olute wrote:

>
> Hi,
>   What is the default datasource used if one uses <sql:query>,
> <sql:update> and <sql:transaction> without the dataSource attribute? or
> no <sql:dataSource ... />

The one set in your web.xml as:

<context-param>
    <param-name>javax.servlet.jsp.jstl.sql.dataSource</param-name>
    <param-value>jdbc/NameOfResourceInServeXmlDS</param-value>
</context-param>


[and have mentioned at the bottom of the web.xml as a resource]

At least that's how I have it working by default.


>   How about if one has this on the top of jsp page:
>  5 <%@ page import="javax.servlet.jsp.jstl.core.Config" %>
>  6  <%
> Config.set(session,"javax.servlet.jsp.jstl.sql.dataSource","jdbc:mys
> ql://192.168.100.1:3306/menagerie,com.mysql.jdbc.Driver,mysql"); %>
>  7 <%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql" %>
> I didnt have user and password setup on the above, is the dataSource
> set-up properly? and how does the sql tags refers to this dataSource?
>    I am using tomcat 4.1.18 + jdk1.4.0_01. Someone has configuration to
> setup the datasource correctly with tomcat? I always had this issue and
> was never ever able to resolve tomcat datasource issue.

There are three steps to setting up JNDI [for JSTL anyway] in Tomcat:

the first is to put:

<context-param>
    <param-name>javax.servlet.jsp.jstl.sql.dataSource</param-name>
    <param-value>jdbc/TimeTrackerDS</param-value>
</context-param>

at the top of your web.xml [under the web-xml tag]

The second is to put:

<resource-ref>
  <description>
    Our datasource.
  </description>
  <res-ref-name>jdbc/TimeTrackerDS</res-ref-name>
  <res-type>javax.sql.DataSource</res-type>
  <res-auth>Container</res-auth>
</resource-ref>

at the bottom of your web.xml [but put it above a
security-constraint/login-config tag if you have those. I'm assuming not
at the moment. The order of web.xml is very important]

Then in your server's server.xml, you need to add a Resource to your
Context, much like:

        <Context path="/timetracker" docBase="timetracker" debug="0"
                 reloadable="true" crossContext="true">
          <Logger className="org.apache.catalina.logger.FileLogger"
                     prefix="localhost_timetracker_log." suffix=".txt"
                  timestamp="true"/>
          <Resource name="jdbc/TimeTrackerDS" auth="Container"
                    type="javax.sql.DataSource"/>
          <ResourceParams name="jdbc/TimeTrackerDS">
            <parameter><name>user</name><value>timetk</value></parameter>
            <parameter><name>password</name><value>huckleberry</value></parameter>
            <parameter><name>driverClassName</name>
              <value>org.gjt.mm.mysql.Driver</value></parameter>
            <parameter><name>driverName</name>
              <value>jdbc:mysql://machinename.flamefew.net/timetk</value>
            </parameter>
          </ResourceParams>
        </Context>


Lastly, place the Jar for your driver [ie mm.mysql..jar] in your
common/lib directory of the Tomcat server.

I find that given all these [and make sure you didn't install the LE,
light-edition of tomcat] that things work.


Hen


---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org