Hi Harald, please apologize that I have not been able to answer you request earlier.
I use connection pooling with all my web projects. Empire-db itself does not do anything to fetch or release a connection at all. The reasons for this are: 1. The requirements for how connections are handled varies for each application type. 2. The user should be able to clearly define the scope his/her transactions Both issues often cause problems with other ORM or DB frameworks like e.g. JPA. For my Web-projects I always use this approach: 1. I have a static method called getConnection that checks if a connection is already available for the request. If not a connection is fetched from the pool (DataSource) and then stored on request scope. 2. I have an interceptor of in JSF a PhaseListener that automatically returns all connections to the pool after the request. If an exception has occurred then a rollback is automatically performed before the connection is returned, otherwise a commit is performed. However one can always commit or rollback manually in the action handler. If you use our Web-extensions (Struts2 or JSF) it is easy to implement connection pooling as you only have to override one method in the application object (e.g. getAppDataSource(DBDatabase db)). So to answer your question: In multi-user, multi-threading applications you really should use connection pooling. I hope this answer is sufficient for you. Best regards Rainer > from: Harald Kirsch [mailto:[email protected]] > to: [email protected] > re: connection pooling with empire-db > > Hi all, > > I have the need to use connection pooling with empire-db. Are there any > best practices or code examples of how to organize this. > > Or asking directly: is it good to use the connection pool for the JDBC > connection and have code like > > conn = datasource.getConnection(); /** get one from the pool **/ > myDbDatabase.open(driver, conn); .... > myDbDatabase.close(); > conn.close(); /** ?? **/ > > or would it be better to somehow create a DataSource that creates > myDbDatabase and pools it? > > Regards, > Harald.
