commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From po...@free.fr
Subject Re: DbUtils Best Practices
Date Wed, 12 Sep 2007 16:33:25 GMT
Hi,
It seems correct, why not, QueryRunner object is thread safe.
Web layer which calls integration layer directly, it's a bad design but this
depends of your project size.

Jérome.



Selon diego.galdi@nurun.it:

> 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()
> 					.getDataSource());
> 	} 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:
>
> QueryManager.getInstance().getQueryRunner().query(...);
>
> Is this correct?
>
> Which is the best practice to use QueryRunner in a web context?
>
> Thanks a lot in advance
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message