Quercus + PostgreSQL + JNDI + PEAR::DB

11 Dec
2009

If you trying to migrate a legacy PHP application which still uses PEAR::DB to Quercus with PostgreSQL and JDBC-Connection Pools accessible through JNDI, this may come handy for you!

1. Create your Datasource e.g. in Glassfish v3’s admin console… I named mine jdbc/postgresDS

2. copy the file pgsqljndi.php to /usr/share/php/DB/pgsqljndi.php (or wherever you include your PEAR stuff from..)

3. change the database connection creation part of your script to this:

1
2
3
4
5
$db = & DB::connect("pgsqljndi://java:comp/env/jdbc/postgresDS");
if(DB::isError($db))
{
// error handling
}

4. remove stuff like this from your scripts

1
$db->query("SET NAMES 'utf-8'; ");

Your database connection with PEAR::DB, Quercus, PostgreSQL, JDBC + JNDI should work now!

Comment Form

top