Search code examples
postgresqljdbcconnection-poolingactivejdbc

How do you use a Connection Pool with ActiveJDBC instead of just Base.open & close everytime?


Right now I'm just writing methods that does Base.open(), do some operation, and then Base.close(). However, this is extremely inefficient especially when lots of these method calls are made, so I'd like to use some kind of connection pool with ActiveJDBC. Is there a way to use something like a connection pool with ActiveJDBC, or some other way to approach this problem instead of doing Base.open() and Base.close() each time I access the DB?

Thanks in advance! :)


Solution

  • Here is an example of using ActiveJDBC with a pool: https://github.com/javalite/activejdbc/blob/master/activejdbc/src/test/java/org/javalite/activejdbc/C3P0PoolTest.java

    However, you still need to open and close a connection, except you are getting a connection from pool and returning back to pool. If you provide more information on what type of application you develop, I can potentially provide better advice

    -- igor