You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by di...@nurun.it on 2007/09/12 15:48:00 UTC
DbUtils Best Practices
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
Re: DbUtils Best Practices
Posted by di...@nurun.it.
Yes, but it's a project requirement, I can't use Spring!!!
;)
Diego
> Have you thought of using Spring's JDBC Dao stuff?
>
> On 9/13/07, pouky@free.fr <po...@free.fr> wrote:
>> add an action in the catch block and this will be perfect
>> ;)
>> Jérome.
>>
>>
>>
>> Selon diego.galdi@nurun.it:
>>
>> > I have changed my class:
>> >
>> > public class QueryManager {
>> >
>> > private static QueryManager queryManager = null;
>> >
>> > private QueryRunner queryRunner = null;
>> >
>> > private QueryManager() {
>> > 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 this.queryRunner;
>> > }
>> >
>> > Is what you meant?
>> >
>> > Thanks
>> >
>> >
>> >
>> >
>> > > sorry, another point...
>> > > queryRunner parameter must be a QueryManager member parameter, you
>> have to
>> > > remove "static"
>> > >
>> > > Selon pouky@free.fr:
>> > >
>> > >> i'm seeing another point. Your QueryManager does not offer the
>> guarantee
>> > >> to
>> > >> be a
>> > >> singleton, you have to declare a private constructor.
>> > >>
>> > >> Jérome.
>> > >>
>> > >>
>> > >> Selon pouky@free.fr:
>> > >>
>> > >> > Selon diego.galdi@nurun.it:
>> > >> >
>> > >> > > Hi,
>> > >> > > I'm using a dao pattern, the call
>> > >> > >
>> > >> > > QueryManager.getInstance().getQueryRunner().query(...);
>> > >> > >
>> > >> > > is executed in my dao object.
>> > >> > >
>> > >> > > Servlet calls dao method.
>> > >> > >
>> > >> > ok.
>> > >> >
>> > >> > > What do you mean with it depends of your project size?
>> > >> > Hi,
>> > >> > If you have a small project it is not mandatory to spend a lot of
>> time
>> > >> in
>> > >> the
>> > >> > abstraction layers, but this is advised. If you implement this
>> > >> approach,
>> > >> life
>> > >> > is
>> > >> > wonderful. :)
>> > >> >
>> > >> > Jérome.
>> > >> >
>> > >> > >
>> > >> > > Thanks a lot
>> > >> > >
>> > >> > > Diego
>> > >> > >
>> > >> > >
>> > >> > > > 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
>> > >> > > >
>> > >> > > >
>> > >> > >
>> > >> > >
>> > >> > >
>> > >> > > ---------------------------------------------------------------------
>> > >> > > 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
>> > >> >
>> > >> >
>> > >>
>> > >>
>> > >>
>> > >> ---------------------------------------------------------------------
>> > >> 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
>> > >
>> > >
>> >
>> >
>> >
>> > ---------------------------------------------------------------------
>> > 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
>>
>>
>
> ---------------------------------------------------------------------
> 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
Re: DbUtils Best Practices
Posted by James Carman <ja...@carmanconsulting.com>.
Have you thought of using Spring's JDBC Dao stuff?
On 9/13/07, pouky@free.fr <po...@free.fr> wrote:
> add an action in the catch block and this will be perfect
> ;)
> Jérome.
>
>
>
> Selon diego.galdi@nurun.it:
>
> > I have changed my class:
> >
> > public class QueryManager {
> >
> > private static QueryManager queryManager = null;
> >
> > private QueryRunner queryRunner = null;
> >
> > private QueryManager() {
> > 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 this.queryRunner;
> > }
> >
> > Is what you meant?
> >
> > Thanks
> >
> >
> >
> >
> > > sorry, another point...
> > > queryRunner parameter must be a QueryManager member parameter, you have to
> > > remove "static"
> > >
> > > Selon pouky@free.fr:
> > >
> > >> i'm seeing another point. Your QueryManager does not offer the guarantee
> > >> to
> > >> be a
> > >> singleton, you have to declare a private constructor.
> > >>
> > >> Jérome.
> > >>
> > >>
> > >> Selon pouky@free.fr:
> > >>
> > >> > Selon diego.galdi@nurun.it:
> > >> >
> > >> > > Hi,
> > >> > > I'm using a dao pattern, the call
> > >> > >
> > >> > > QueryManager.getInstance().getQueryRunner().query(...);
> > >> > >
> > >> > > is executed in my dao object.
> > >> > >
> > >> > > Servlet calls dao method.
> > >> > >
> > >> > ok.
> > >> >
> > >> > > What do you mean with it depends of your project size?
> > >> > Hi,
> > >> > If you have a small project it is not mandatory to spend a lot of time
> > >> in
> > >> the
> > >> > abstraction layers, but this is advised. If you implement this
> > >> approach,
> > >> life
> > >> > is
> > >> > wonderful. :)
> > >> >
> > >> > Jérome.
> > >> >
> > >> > >
> > >> > > Thanks a lot
> > >> > >
> > >> > > Diego
> > >> > >
> > >> > >
> > >> > > > 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
> > >> > > >
> > >> > > >
> > >> > >
> > >> > >
> > >> > >
> > >> > > ---------------------------------------------------------------------
> > >> > > 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
> > >> >
> > >> >
> > >>
> > >>
> > >>
> > >> ---------------------------------------------------------------------
> > >> 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
> > >
> > >
> >
> >
> >
> > ---------------------------------------------------------------------
> > 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
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org
Re: DbUtils Best Practices
Posted by po...@free.fr.
add an action in the catch block and this will be perfect
;)
Jérome.
Selon diego.galdi@nurun.it:
> I have changed my class:
>
> public class QueryManager {
>
> private static QueryManager queryManager = null;
>
> private QueryRunner queryRunner = null;
>
> private QueryManager() {
> 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 this.queryRunner;
> }
>
> Is what you meant?
>
> Thanks
>
>
>
>
> > sorry, another point...
> > queryRunner parameter must be a QueryManager member parameter, you have to
> > remove "static"
> >
> > Selon pouky@free.fr:
> >
> >> i'm seeing another point. Your QueryManager does not offer the guarantee
> >> to
> >> be a
> >> singleton, you have to declare a private constructor.
> >>
> >> Jérome.
> >>
> >>
> >> Selon pouky@free.fr:
> >>
> >> > Selon diego.galdi@nurun.it:
> >> >
> >> > > Hi,
> >> > > I'm using a dao pattern, the call
> >> > >
> >> > > QueryManager.getInstance().getQueryRunner().query(...);
> >> > >
> >> > > is executed in my dao object.
> >> > >
> >> > > Servlet calls dao method.
> >> > >
> >> > ok.
> >> >
> >> > > What do you mean with it depends of your project size?
> >> > Hi,
> >> > If you have a small project it is not mandatory to spend a lot of time
> >> in
> >> the
> >> > abstraction layers, but this is advised. If you implement this
> >> approach,
> >> life
> >> > is
> >> > wonderful. :)
> >> >
> >> > Jérome.
> >> >
> >> > >
> >> > > Thanks a lot
> >> > >
> >> > > Diego
> >> > >
> >> > >
> >> > > > 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
> >> > > >
> >> > > >
> >> > >
> >> > >
> >> > >
> >> > > ---------------------------------------------------------------------
> >> > > 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
> >> >
> >> >
> >>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> 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
> >
> >
>
>
>
> ---------------------------------------------------------------------
> 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
Re: DbUtils Best Practices
Posted by di...@nurun.it.
I have changed my class:
public class QueryManager {
private static QueryManager queryManager = null;
private QueryRunner queryRunner = null;
private QueryManager() {
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 this.queryRunner;
}
Is what you meant?
Thanks
> sorry, another point...
> queryRunner parameter must be a QueryManager member parameter, you have to
> remove "static"
>
> Selon pouky@free.fr:
>
>> i'm seeing another point. Your QueryManager does not offer the guarantee
>> to
>> be a
>> singleton, you have to declare a private constructor.
>>
>> Jérome.
>>
>>
>> Selon pouky@free.fr:
>>
>> > Selon diego.galdi@nurun.it:
>> >
>> > > Hi,
>> > > I'm using a dao pattern, the call
>> > >
>> > > QueryManager.getInstance().getQueryRunner().query(...);
>> > >
>> > > is executed in my dao object.
>> > >
>> > > Servlet calls dao method.
>> > >
>> > ok.
>> >
>> > > What do you mean with it depends of your project size?
>> > Hi,
>> > If you have a small project it is not mandatory to spend a lot of time
>> in
>> the
>> > abstraction layers, but this is advised. If you implement this
>> approach,
>> life
>> > is
>> > wonderful. :)
>> >
>> > Jérome.
>> >
>> > >
>> > > Thanks a lot
>> > >
>> > > Diego
>> > >
>> > >
>> > > > 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
>> > > >
>> > > >
>> > >
>> > >
>> > >
>> > > ---------------------------------------------------------------------
>> > > 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
>> >
>> >
>>
>>
>>
>> ---------------------------------------------------------------------
>> 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
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org
Re: DbUtils Best Practices
Posted by po...@free.fr.
sorry, another point...
queryRunner parameter must be a QueryManager member parameter, you have to
remove "static"
Selon pouky@free.fr:
> i'm seeing another point. Your QueryManager does not offer the guarantee to
> be a
> singleton, you have to declare a private constructor.
>
> Jérome.
>
>
> Selon pouky@free.fr:
>
> > Selon diego.galdi@nurun.it:
> >
> > > Hi,
> > > I'm using a dao pattern, the call
> > >
> > > QueryManager.getInstance().getQueryRunner().query(...);
> > >
> > > is executed in my dao object.
> > >
> > > Servlet calls dao method.
> > >
> > ok.
> >
> > > What do you mean with it depends of your project size?
> > Hi,
> > If you have a small project it is not mandatory to spend a lot of time in
> the
> > abstraction layers, but this is advised. If you implement this approach,
> life
> > is
> > wonderful. :)
> >
> > Jérome.
> >
> > >
> > > Thanks a lot
> > >
> > > Diego
> > >
> > >
> > > > 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
> > > >
> > > >
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > 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
> >
> >
>
>
>
> ---------------------------------------------------------------------
> 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
Re: DbUtils Best Practices
Posted by po...@free.fr.
i'm seeing another point. Your QueryManager does not offer the guarantee to be a
singleton, you have to declare a private constructor.
Jérome.
Selon pouky@free.fr:
> Selon diego.galdi@nurun.it:
>
> > Hi,
> > I'm using a dao pattern, the call
> >
> > QueryManager.getInstance().getQueryRunner().query(...);
> >
> > is executed in my dao object.
> >
> > Servlet calls dao method.
> >
> ok.
>
> > What do you mean with it depends of your project size?
> Hi,
> If you have a small project it is not mandatory to spend a lot of time in the
> abstraction layers, but this is advised. If you implement this approach, life
> is
> wonderful. :)
>
> Jérome.
>
> >
> > Thanks a lot
> >
> > Diego
> >
> >
> > > 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
> > >
> > >
> >
> >
> >
> > ---------------------------------------------------------------------
> > 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
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org
Re: DbUtils Best Practices
Posted by po...@free.fr.
Selon diego.galdi@nurun.it:
> Hi,
> I'm using a dao pattern, the call
>
> QueryManager.getInstance().getQueryRunner().query(...);
>
> is executed in my dao object.
>
> Servlet calls dao method.
>
ok.
> What do you mean with it depends of your project size?
Hi,
If you have a small project it is not mandatory to spend a lot of time in the
abstraction layers, but this is advised. If you implement this approach, life is
wonderful. :)
Jérome.
>
> Thanks a lot
>
> Diego
>
>
> > 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
> >
> >
>
>
>
> ---------------------------------------------------------------------
> 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
Re: DbUtils Best Practices
Posted by di...@nurun.it.
Hi,
I'm using a dao pattern, the call
QueryManager.getInstance().getQueryRunner().query(...);
is executed in my dao object.
Servlet calls dao method.
What do you mean with it depends of your project size?
Thanks a lot
Diego
> 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
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org
Re: DbUtils Best Practices
Posted by po...@free.fr.
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