users@glassfish.java.net

Re: Does the jdbc pool manager support setting the defaultAutoCommit?

From: <glassfish_at_javadesktop.org>
Date: Thu, 26 Jul 2007 03:04:10 PDT

1) What does the following code snippet return ? it returns "false" for me.
------------------------------------------------------------------------------------------------------------------------------------
import javax.sql.ConnectionPoolDataSource;
import java.sql.Connection;

public class PostgresTest {

    public static void main(String[] args) throws Exception {
                    ConnectionPoolDataSource ds = initializeDataSource();
        Connection con = ds.getPooledConnection().getConnection();
        System.out.println("Autocommit : " + con.getAutoCommit());
        con.close();

    }

    private static org.postgresql.ds.PGConnectionPoolDataSource initializeDataSource() {
        org.postgresql.ds.PGConnectionPoolDataSource ds = new org.postgresql.ds.PGConnectionPoolDataSource();
        ds.setUser("db-user");
        ds.setPassword("db-password");
        ds.setDatabaseName("core-db");
        ds.setPortNumber(5432);
        ds.setServerName("HOST_NAME");
        ds.setDefaultAutoCommit(false);
        return ds;
    }
}
------------------------------------------------------------------------------------------------------------------------------------

2)
Even in glassfish, setting defaultAutoCommit= false, returns connections with autocommit as false.
Pool Manager does not interpret these driver properties.
What type of component in which you do getConnection() ? (standard java-ee like servlet/ejb or others ).
I have set transaction-attribute in my descriptor as "NotSupported" (so that TransactionManager is not involved) and it works appropriately w.r.t defaultAutoCommit value.
[Message sent by forum member 'jr158900' (jr158900)]

http://forums.java.net/jive/thread.jspa?messageID=228313