commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject DbUtils Best Practices
Date Wed, 12 Sep 2007 13:48:00 GMT
Hi, I'm developing a web application using DbUtils classes to execute
queries and so on.

I user QueryRunner class with a DataSource.

I red this class is thread safe, so I implemented a Singleton to instance
QueryRunner only once.

This is my code:

public class QueryManager {

 private static QueryManager queryManager = null;

 private static QueryRunner queryRunner = null;

 static {
   try {
	queryRunner = new QueryRunner(DataSourceSingleton.getInstance()
	} catch (Exception e) {

 public static QueryManager getInstance() {
    if (queryManager == null) {
	queryManager = new QueryManager();
    return queryManager;

 public QueryRunner getQueryRunner() {
   return queryRunner;

In my servlets I use:


Is this correct?

Which is the best practice to use QueryRunner in a web context?

Thanks a lot in advance

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message