You certainly can define your MySQL JNDI Datasource within the
<GlobalResourceParams> node in server.xml.  This is how I have it set up
currently and everything works fine (I am running Tomcat 4.1.24).  I sent
the following out the other day in response to a different thread, but it
applies here as well:

    The global DataSource definition
    --------------------------------

        <!-- Global JNDI resources -->
        <GlobalNamingResources>

            <!-- Editable user database that can also be used by JNDI
DatabaseRealm to authenticate users -->
            <Resource name="jdbc/MySQLConnectPool" 
                      auth="Container" 
                      type="javax.sql.DataSource" />

            <ResourceParams name="jdbc/MySQLConnectPool" >
                        
                <parameter>
                    <name>username</name>
                    <value>????????</value>
                </parameter>

                <parameter>
                    <name>password</name>
                    <value>????????</value>
                </parameter>

                <parameter>
                    <name>driverClassName</name>
                    <value>com.mysql.jdbc.Driver</value>
                </parameter>

                <parameter>
                    <name>url</name>
                    <value>jdbc:mysql://<your IP here>:3306/<your DB name
here>?autoReconnect=true</value>
                </parameter>
                                
                <parameter>
                    <name>removeAbandoned</name>
                    <value>true</value>
                </parameter>
                                
                <parameter>
                    <name>removeAbandonedTimeout</name>
                    <value>60</value>
                </parameter>
                                
                <parameter>
                    <name>logAbandoned</name>
                    <value>true</value>
                </parameter>
                                
                <parameter>
                    <name>maxActive</name>
                    <value>200</value>
                </parameter>
                                
                <parameter>
                    <name>maxIdle</name>
                    <value>30000</value>
                </parameter>
                                
                <parameter>
                    <name>maxWait</name>
                    <value>100</value>
                </parameter>
                                
            </ResourceParams>

        </GlobalNamingResources>


    Realm definition using global DataSource
    ----------------------------------------

        <Realm  
            className="org.apache.catalina.realm.DataSourceRealm" 
            dataSourceName="jdbc/MySQLConnectPool"
            userTable="customers" 
            userNameCol="customer_username" 
            userCredCol="customer_password"
            userRoleTable="roles" 
            roleNameCol="role" 
            debug="0"
        />


    Context reference to global DataSource
    --------------------------------------

        <ResourceLink name="jdbc/MySQLConnectPool"
                      global="jdbc/MySQLConnectPool"
                      type="javax.sql.DataSource" />
                                                  

Hope this helps!!

Thanks,

Scott Stewart


-----Original Message-----
From: Geralyn M Hollerman [mailto:[EMAIL PROTECTED]
Sent: Thursday, July 31, 2003 1:24 PM
To: [EMAIL PROTECTED]
Subject: Re: Problem confinguring MySQL JNDI Datasource RH Linux 7.2


[EMAIL PROTECTED] wrote:

> I have followed instructions provided for configuring JNDI Datasource for
MySQL
(http://jakarta.apache.org/tomcat/tomcat-4.1-doc/printer/jndi-datasource-exa
mples-howto.html), and am running into problem on RedHat Linux 7.2.
> 
> Here is my configuration:
> 
> RedHat Linux 7.2 (kernel-2.4.7-10)
> Tomcat 4.1.24 (Clean install)
> MySQL 4.0.12
> Using mysql-connector-java-3.0.8-stable-bin.jar (driver installed in
$CATALINA_HOME/common/lib/)
> 
> I copied the example code straight from the URL and made following change
to DBTest context for >my system and mysql driver.
> 
> <server.xml snippet>
> !-- Class name for mm.mysql JDBC driver -->
>                         <parameter>
>                                 <name>driverClassName</name>
>                                 <value>com.mysql.jdbc.Driver</value>
>                         </parameter>
> 
>     <!-- The JDBC connection url for connecting to your MySQL dB.
>          The autoReconnect=true argument to the url makes sure that the
>          mm.mysql JDBC Driver will automatically reconnect if mysqld
closed the
>          connection.  mysqld by default closes idle connections after 8
hours.
>          -->
>                         <parameter>
>                                 <name>url</name>
>                                 <value>jdbc:mysql://<dns name of
system>:3306/javatest?autoReconnect=true</value>
>                         </parameter>
>                 </ResourceParams>
> </server.xml snippet>
> 
> I get following error in catalina.out when bringing up test.jsp that uses
the datasource.
> 
> <catalina.out error>
>         DBCP borrowObject failed: java.sql.SQLException: Server connection
failure during >transaction.
> 
> Does any one have any advice on what may be wrong?
> 
> I have successfully configured Tomcat 4.1.24 using the JNDI datasource
howto example code on >Windows 2000 using
mysql-connector-java-3.0.8-stable-bin.jar, with MySQL 3.23.44.

Is that server.xml snippet in <GlobalResourceParams> or its own
<Context>? It needs to be in its own <Context>. Also, where are your
username and password defined? I'm using 4.1.24, and I get a message in
catalina.out if I leave those out (they should be defined in the
<ResourceParams> as parameters). According to some other questions I've
seen about this, that error often comes up due to a permissions problem
with MySQL - does the user you're using have access rights (in MySQL)
for the db?

-- 
Lynn Hollerman.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to