You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Jakarta Tomcat Newsgroup (@Basebeans.com)" <ja...@basebeans.com> on 2002/07/09 01:55:01 UTC

Tyrex 1.0 and Getting a Connection Pool in 4.1.x

Subject: Tyrex 1.0 and Getting a Connection Pool in 4.1.x
From: "Matt Raible" <ma...@raibledesigns.com>
 ===
In Tomcat 4.0.x, I am able to get a database connection via JNDI using the
following code:

import tyrex.jdbc.xa.EnabledDataSource;

    public Connection getPooledConnection() throws ServiceLocatorException
    {
        try {
            Context initCtx = new InitialContext();
            Context envCtx = (Context) initCtx.lookup("java:comp/env");
            ds = (EnabledDataSource) envCtx.lookup(Constants.JNDI_DB);
        } catch (NamingException ex) {
            logCat.error("NamingException: " + ex.getMessage());
            throw new ServiceLocatorException(ex);
        }

        try {
            con = ds.getConnection();
        } catch (SQLException ex) {
            logCat.error("SQLException: " + ex.getMessage());
            throw new ServiceLocatorException(ex);
        }
        return con;
    }

What do I need to change for this to work in 4.1.x?  Is there any way to
make the changes backward compatible with 4.0.x?

Thanks,

Matt



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Tyrex 1.0 and Getting a Connection Pool in 4.1.x

Posted by Andrew Conrad <an...@msn.com>.
Download tyrex. It's not included by default in 4.1.x.  Also, add a
factory parameter and reference the DataSource factory of Tyrex, since
it is no longer the default DataSource factory of Tomcat (DBCP is).

- Andrew

-----Original Message-----
From: Jakarta Tomcat Newsgroup
[mailto:@Basebeans.comjakarta-tom@basebeans.com] 
Sent: Monday, July 08, 2002 7:55 PM
To: tomcat-user@jakarta.apache.org
Subject: Tyrex 1.0 and Getting a Connection Pool in 4.1.x


Subject: Tyrex 1.0 and Getting a Connection Pool in 4.1.x
From: "Matt Raible" <ma...@raibledesigns.com>
 ===
In Tomcat 4.0.x, I am able to get a database connection via JNDI using
the following code:

import tyrex.jdbc.xa.EnabledDataSource;

    public Connection getPooledConnection() throws
ServiceLocatorException
    {
        try {
            Context initCtx = new InitialContext();
            Context envCtx = (Context) initCtx.lookup("java:comp/env");
            ds = (EnabledDataSource) envCtx.lookup(Constants.JNDI_DB);
        } catch (NamingException ex) {
            logCat.error("NamingException: " + ex.getMessage());
            throw new ServiceLocatorException(ex);
        }

        try {
            con = ds.getConnection();
        } catch (SQLException ex) {
            logCat.error("SQLException: " + ex.getMessage());
            throw new ServiceLocatorException(ex);
        }
        return con;
    }

What do I need to change for this to work in 4.1.x?  Is there any way to
make the changes backward compatible with 4.0.x?

Thanks,

Matt



--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>