Hi Dave

Despite my posting - and I really hope someone chips in concerning the
question I raised about the <resource-ref> being redundant in the deployment
descriptor (!) - the first thing to say is, have faith!

Connection pooling works, and it is actually quite simple, so do not give up
on it.

> I've tried having the connection defined in
> $JAKARTA_HOME/conf/server.xml and in
> $JAKARTA_HOME/Catalina/localhost/<app_name>.xml

Stick to the app-name.xml - do not put anything in the server.xml.

You need to tell us what errors you are getting.

It will also help if you copy and paste the *exact code* elements from the
app-name.xml, and the method that is trying to look up the DataSource.

The context fragment bit should look like this:


    <Resource name="jdbc/postgres"
              auth="Container"
              type="javax.sql.DataSource"/>

    <ResourceParams name="jdbc/postgres">
        ...
    </ResourceParams>
    

The deployment descriptor bit should look like this:


    <resource-ref>
        <description>DB Connection</description>
        <res-ref-name>jdbc/postgres</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
    </resource-ref>


And then the JNDI lookup method should look like this:

    
    public DataSource getDataSource() {
        try {
            return ( DataSource )new InitialContext().
                lookup( "java:comp/env/jdbc/postgres" );
        } catch ( ... ) {
            ...
        }
    }


The above can be written in a more long-winded way, but that one line does
the job.

Harry


> I have to say I'm having a large number of issues with JNDI and MySQL
> 
> I'm using TC 5 on Fedora Core 1 with the JDBC / MySQL 3.1.1 Alpha
> Connector (after I had no luck getting the 3.0.11 Stable connector
> working either)
> 
> I've been looking at various how-to's and other doco on the whole thing
> but don't seem to be getting very far with the whole thing.
> 
> I've tried having the connection defined in
> $JAKARTA_HOME/conf/server.xml and in
> $JAKARTA_HOME/Catalina/localhost/<app_name>.xml
> 
> I have resource-ref defined in the <app_name>/WEB-INF/web.xml but in
> spite of all this I seem to be getting nowhere... (which is a pain) I've
> managed to create a straight JDBC connection though so I know that the
> DB is accepting connections on the relevant user.
> 
> TIA


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

Reply via email to