import java.sql.*;
import java.util.*;
import java.lang.reflect.*;
+import org.postgresql.PGConnection;
/**
* PostgreSQL implementation of the PooledConnection interface. This shouldn't
* @see ConnectionPool
*
* @author Aaron Mulder (ammulder@chariotsolutions.com)
- * @version $Revision: 1.5 $
+ * @version $Revision: 1.6 $
*/
public class PooledConnectionImpl implements PooledConnection
{
con.setAutoCommit(autoCommit);
ConnectionHandler handler = new ConnectionHandler(con);
last = handler;
- Connection con = (Connection)Proxy.newProxyInstance(getClass().getClassLoader(), new Class[]{Connection.class}, handler);
+ Connection con = (Connection)Proxy.newProxyInstance(getClass().getClassLoader(), new Class[]{Connection.class, PGConnection.class}, handler);
last.setProxy(con);
return con;
}
throw e.getTargetException();
}
}
- // All the rest is from the Connection interface
+ // All the rest is from the Connection or PGConnection interface
if (method.getName().equals("isClosed"))
{
return con == null ? Boolean.TRUE : Boolean.FALSE;
import junit.framework.TestCase;
import org.postgresql.test.TestUtil;
import org.postgresql.jdbc2.optional.BaseDataSource;
+import org.postgresql.PGConnection;
import java.sql.*;
import java.util.*;
* tests.
*
* @author Aaron Mulder (ammulder@chariotsolutions.com)
- * @version $Revision: 1.4 $
+ * @version $Revision: 1.5 $
*/
public abstract class BaseDataSourceTest extends TestCase
{
}
}
+ /**
+ * Test to make sure that PGConnection methods can be called on the
+ * pooled Connection.
+ */
+ public void testPGConnection()
+ {
+ try
+ {
+ con = getDataSourceConnection();
+ ((PGConnection)con).getEncoding().name();
+ con.close();
+ }
+ catch (Exception e)
+ {
+ fail("Unable to call PGConnection method on pooled connection due to "+e.getClass().getName()+" ("+e.getMessage()+")");
+ }
+ }
+
/**
* Uses the mini-JNDI implementation for testing purposes
*/