JdbcProgressDriver and Java Database connection pooling services

rom3ro

New Member
hello,

i write a web application base on struts2 (tomcat 5.5) and i trouble with differents Database connection pooling services with progress 9.1D.

In fact, the pooling service fail when it try to load class of jdbc progress driver.

I done test with
- DBCP
- Proxool
- c3p0

However, the three pooling service above work with the jdbc hsqldb drivers and i can use the jdbc progress driver without pooling services.

Have you ever use a pooling service with the jdbc progress driver otherwise in web application how control you the connections.

thanks

Thibault

PS:I make specify than I can connect to db with the SQL Explorer tool and with examples give in Progress JDBC Configuration white paper.
 
i've foud!

JdbcProgressDrivers implement jdbcd 2.0, so for database connection pooling services called above the driver not work. In fact they work with 2.2.

So i implemented a class called JdbcProgressDriverCustom which extends JdbcProgressDrivers and defined getHoldability() (requier by dbcp).

After i create a CustomProgressCpdsFactory (extend java.naming.ObjcdtFactory) which create a dbcp pool service.

With both class i can setup a ressource in tomcat 5.5 server.xml and make a reference in web.xml app.

In this way i can connect to progress sgbd by use of javax.sql.DataSource by means of jndy loockup.

server.xml:
Code:
<Resource auth="Container" description="infointv database on progress sgbd"
factory="com.toto.ric.util.CustomProgressCpdsFactory"
name="jdbc/progressDB" type="javax.sql.DataSource"
conf="ds_progressDB.xml" />
web.xml:
Code:
<resource-ref>
<description>DB Connection for infointv</description>
<res-ref-name>jdbc/progressDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
CustomProgressCpdsFactory :
Code:
public class CustomProgressCpdsFactory implements ObjectFactory {

    public Object getObjectInstance(Object obj, Name name, Context ctx, Hashtable<?, ?> environment) throws Exception {

        Reference ref = (Reference) obj;
        Enumeration<RefAddr> addrs = ref.getAll();
        while (addrs.hasMoreElements()) {
            RefAddr addr = (RefAddr) addrs.nextElement();
            String nameAddr = addr.getType();
            String valueAddr = (String) addr.getContent();
            if (nameAddr.equals("conf")) {
                String strFile = valueAddr;
                PoolingDataSource dsp = createDS(strFile);
                return dsp;
            }
        }

        return null;
    }

    private PoolingDataSource createDS(String strFile) throws Exception, InvalidPropertiesFormatException, IOException,
            NullPointerException {

        FileInputStream inputStream = new FileInputStream("src" + File.separator + strFile);
        Properties p = new Properties();
        p.loadFromXML(inputStream);

        String driverClassName = p.getProperty("driverClassName");
        String url = p.getProperty("url");
        String username = p.getProperty("username");
        String password = p.getProperty("password");

        String maxActive = p.getProperty("maxActive");
        String maxIdle = p.getProperty("maxIdle");
        String minIdle = p.getProperty("minIdle");
        String maxWait = p.getProperty("maxWait");

        // String initialSize = p.getProperty("initialSize");
        // String removeAbandoned = p.getProperty("removeAbandoned");
        // String removeAbandonedTimeout = p.getProperty("removeAbandonedTimeout");
        // String logAbandoned = p.getProperty("logAbandoned");

        try {
            Class.forName(driverClassName);
        } catch (ClassNotFoundException e) {
            throw new ClassNotFoundException("Not unable to load conf file : " + driverClassName);
        }

        GenericObjectPool.Config conf = new GenericObjectPool.Config();
        conf.maxWait = Integer.parseInt(maxWait);
        conf.maxActive = Integer.parseInt(maxActive);
        conf.maxIdle = Integer.parseInt(maxIdle);
        conf.minIdle = Integer.parseInt(minIdle);

        ObjectPool connectionPool = new GenericObjectPool(null, conf);

        ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(url, username, password);

        @SuppressWarnings("unused")
        PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory(connectionFactory,
                connectionPool, null, null, false, true);

        return new PoolingDataSource(connectionPool);
    }
}
example in jsp with jstl:
Code:
<sql:query var="row" dataSource="jdbc/progressDB">
select * from pub.bar
</sql:query>
example in java code:
Code:
Context ctx = (Context) new InitialContext().lookup("java:comp/env");
DataSource ds = (DataSource) ctx.lookup("jdbc/progressDB");
Connection c = ds.getConnection();
Statement stmt = c.createStatement();
ResultSet rs = stmt.executeQuery("select * from pub.bar");
 
Back
Top