Using SimpleJDBCConnectionPool

Hi,
I am trying to use a SimpleJDBCConnectionPool with my postgre database and Vaadin 6.8.7. The idea being that many users access the application through their browser and each one gets connections from the pool and the connection stays open. I have the following code:

public class db {

static JDBCConnectionPool pool;

public db() {}


public db(String user, String password, String server, String db_name) {
    super(user, password, server, db_name);
    
    if (pool == null)
    {
        try
        {
            pool = new SimpleJDBCConnectionPool( "org.postgresql.Driver",
                    "jdbc:postgresql://localhost:5432/"+ db_name, user, password, 2, 5);
        }
        catch(SQLException e)
        {           
        }
    }

and then somewhere else i do,

         FreeformQuery selectQuery = new FreeformQuery("SELECT * FROM users LEFT JOIN addresses on users.addressId = addresses.addressId", pool);
        
        ResultSet rs = selectQuery.getResults(0, 0);

I have 2 problems:

  1. This does not work unless I do selectQuery.beginTransaction(); before calling getResults() but I don’t want to start a transaction for SELECT queries. I just want to pass in the pool and let it use a connection and keep the connection open!

  2. For UPDATE and INSERT queries, I also want to open a connection and keep it open. If I call beginTransaction(), it sets autoCommit to false and then I have to call commit() which closes the connection. Doesn’t make sense coz the reason I am using a connection pool is so that the connection can stay open!

Kindly help.Thanks!