Return-Path: Delivered-To: apmail-incubator-empire-db-user-archive@minotaur.apache.org Received: (qmail 33551 invoked from network); 27 Aug 2010 12:32:04 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 27 Aug 2010 12:32:04 -0000 Received: (qmail 53909 invoked by uid 500); 27 Aug 2010 12:32:04 -0000 Delivered-To: apmail-incubator-empire-db-user-archive@incubator.apache.org Received: (qmail 53848 invoked by uid 500); 27 Aug 2010 12:32:02 -0000 Mailing-List: contact empire-db-user-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: empire-db-user@incubator.apache.org Delivered-To: mailing list empire-db-user@incubator.apache.org Received: (qmail 53840 invoked by uid 99); 27 Aug 2010 12:32:01 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 Aug 2010 12:32:01 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [88.79.172.157] (HELO mail.esteam.de) (88.79.172.157) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 Aug 2010 12:31:57 +0000 Content-class: urn:content-classes:message Subject: re: About the DBDatabase instance opened in a web application MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01CB45E3.C954A34E" Date: Fri, 27 Aug 2010 14:31:34 +0200 X-MimeOLE: Produced By Microsoft Exchange V6.5 Message-ID: In-Reply-To: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: re: About the DBDatabase instance opened in a web application Thread-Index: ActF0aFQFXj2CDtnRMqBh+l2Yn3YnQAEf/Jw References: From: =?iso-8859-1?Q?Rainer_D=F6bele?= To: This is a multi-part message in MIME format. ------_=_NextPart_001_01CB45E3.C954A34E Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Excactly. =20 from: exxos [mailto:hatufr@gmail.com]=20 to: empire-db-user@incubator.apache.org re: Re: About the DBDatabase instance opened in a web application =20 Hi Rainer, Thank you very much for your explanation. To summarize, only one db instance (DBDatabase.open) is required for the = whole application. The result can be stored in a static context or in = the session of the application (i.e. static class) Do we understand each other? Regards, exxos. On Thu, Aug 26, 2010 at 8:33 PM, Rainer Dbele wrote: Hi exxos, sorry but I have been on a business trip and not been able to answer. The intention is to open the database once in the startup code of your = application, i.e. when the webapp is started on the application server = and before handling any requests. We then normally first check whether the actual data model of the db = matches your internal data model object, either by comparing each table = and column (there is some code to do that supplied with the Oracle = driver) or simply by storing a version stamp in a special table and = comparing this version stamp to ours. As the DBDatabase.open does not keep the supplied connection you should = return it back to your connection pool after the open has been = performed. For each request you should then obtain a connection from the = pool and use it for the entire request (in opposition to fetch a new = connection for every operation and return it immediately). We normally = see the whole request as a transaction that we either commit or rollback = at the end of the request, depending on whether an error occurred or = not. For simplicity and to be able to make the connection configurable in our = config file, we do not use a connection pool in our web exsamples but of = course we recommend to do so and the overall layout of your = empire-db-example-struts2 is quite a good example for that.=20 All you need to with this example is to create a connection pool and = provide a different implementation for the getPooledConnection() and = releaseConnection(Connection conn) in the class = org.apache.empire.struts2.websample.web.SampleApplication to obtain and = return a connection from the pool rather then use the static one that we = create at the start and that is held on the application object. Every time a connection is needed it is then fetched via the = SampleRequest object, which requests it once and release it when the = request ends and exit is called. I hope this answers your question. Regards Rainer from: exxos [mailto:hatufr@gmail.com]=20 to: empire-db-user@incubator.apache.org re: Re: About the DBDatabase instance opened in a web application Hi Rainer, We need your opinion on that. Could you please add a comment, it will be = great? Regards, exxos. On Tue, Aug 24, 2010 at 10:12 AM, Francis De Brabandere = wrote: Hi Exxos, I think it's better to wait for Rainer to respond on this one. I would personally not cache the DB on application level but he has way more experience with empire-db. Creating a class instance is cheap, and the db.open does not do that much (select the correct database on the connection and set up the sequence table object). Cheers, Francis On Tue, Aug 24, 2010 at 9:44 AM, exxos wrote: > Hi Francis, > > Just to be sure about what we are discussing here. This is about the > following steps: > > MyDB db =3D new MyDB(); > Connection conn =3D .getConnection(); > DBDatabaseDriver driver =3D new DBDatabaseDriverXXX(); > db.open(driver, conn); > > Could you confirm that the instance "db" does not have to be put in > application session (or in a the static context). > According to your previous answer, for performance purpose, it is = better to > reopen and close it for each DB request. > > Thank you to confirm. > > Regards, > exxos. > > > On Tue, Aug 24, 2010 at 1:20 AM, Francis De Brabandere = > wrote: >> >> Oops, thats the answer to a different question but somehow still = valid >> as you should return your connection to the pool at the end of the >> request. >> >> You could have a look at the SampleRequest/SampleApplication in the >> struts2 example but I have the impression that that example is not >> that great as I uses one connection on application level which is not >> what you should do on a production system. >> >> Maybe I can add a wicket or plain servlet example one day... >> >> These are all good questions :-) might add this one to the faq >> >> Rainer? >> >> Cheers, >> Francis >> >> On Tue, Aug 24, 2010 at 12:51 AM, Francis De Brabandere >> wrote: >> > Open and close on each request. For higher performance better have >> > some kind of connection pool like c3po >> > (http://http://sourceforge.net/projects/c3p0/) or apache commons = dbcp >> > or whatever pooling your appserver has/supports. >> > >> > Cheers, >> > Francis >> > >> > On Tue, Aug 24, 2010 at 12:43 AM, exxos wrote: >> >> Hi, >> >> >> >> Probably a "simple" question... >> >> >> >> For a web application, what is preferable? >> >> >> >> Keeping a DBDatabase instance opened (and attached to a driver) in = the >> >> application session (as static for example) or open and close it = each >> >> time a >> >> db request? >> >> >> >> >> >> Regards, >> >> exxos. >> >> >> > >> > >> > >> > -- >> > http://www.somatik.be >> > Microsoft gives you windows, Linux gives you the whole house. >> > >> >> >> >> -- >> http://www.somatik.be >> Microsoft gives you windows, Linux gives you the whole house. > > -- http://www.somatik.be Microsoft gives you windows, Linux gives you the whole house. =20 ------_=_NextPart_001_01CB45E3.C954A34E Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable

Excactly.

 

from: exxos [mailto:hatufr@gmail.com]
to: empire-db-user@incubator.apache.org
re: Re: About the DBDatabase instance opened in a web = application

 

Hi Rainer,

Thank you very much for your explanation.

To summarize, only one db instance (DBDatabase.open) is required for the = whole application. The result can be stored in a static context or in the = session of the application (i.e. static class)

Do we understand each other?

Regards,
exxos.


On Thu, Aug 26, 2010 at 8:33 PM, Rainer Dbele = <doebele@esteam.de> = wrote:

Hi exxos,

sorry but I have been on a business trip and not been able to = answer.

The intention is to open the database once in the startup code of your = application, i.e. when the webapp is started on the application server and before = handling any requests.

We then normally first check whether the actual data model of the db = matches your internal data model object, either by comparing each table and column = (there is some code to do that supplied with the Oracle driver) or simply by = storing a version stamp in a special table and comparing this version stamp to = ours.

As the DBDatabase.open does not keep the supplied connection you should = return it back to your connection pool after the open has been performed. For each request you should then obtain a connection from the pool and use it for = the entire request (in opposition to fetch a new connection for every = operation and return it immediately). We normally see the whole request as a = transaction that we either commit or rollback at the end of the request, depending on = whether an error occurred or not.

For simplicity and to be able to make the connection configurable in our = config file, we do not use a connection pool in our web exsamples but of course = we recommend to do so and the overall layout of your = empire-db-example-struts2 is quite a good example for that.

All you need to with this example is to create a connection pool and provide = a different implementation for the getPooledConnection() and releaseConnection(Connection conn) in the class org.apache.empire.struts2.websample.web.SampleApplication to obtain and = return a connection from the pool rather then use the static one that we create = at the start and that is held on the application object.

Every time a connection is needed it is then fetched via the SampleRequest = object, which requests it once and release it when the request ends and exit is = called.

I hope this answers your question.

Regards

Rainer

from: exxos [mailto:hatufr@gmail.com] =

re: Re: About the DBDatabase = instance opened in a web application

Hi Rainer,

We need your opinion on that. Could you please add a comment, it will be = great?

Regards,
exxos.

On Tue, Aug 24, 2010 at 10:12 AM, Francis De = Brabandere <francisdb@gmail.com> wrote:

Hi Exxos,

I think it's better to wait for Rainer to respond on this one. I = would
personally not cache the DB on application level but he has way more
experience with empire-db. Creating a class instance is cheap, and = the
db.open does not do that much (select the correct database on the
connection and set up the sequence table object).

Cheers,
Francis


On Tue, Aug 24, 2010 at 9:44 AM, exxos <hatufr@gmail.com> wrote:
> Hi Francis,
>
> Just to be sure about what we are discussing here. This is about = the
> following steps:
>
> MyDB db =3D new MyDB<DBDatabase>();
> Connection conn =3D <DataSrouce>.getConnection();
> DBDatabaseDriver driver =3D new DBDatabaseDriverXXX();
> db.open(driver, conn);
>
> Could you confirm that the instance "db" does not have to = be put in
> application session (or in a the static context).
> According to your previous answer, for performance purpose, it is = better to
> reopen and close it for each DB request.
>
> Thank you to confirm.
>
> Regards,
> exxos.
>
>
> On Tue, Aug 24, 2010 at 1:20 AM, Francis De Brabandere <francisdb@gmail.com>
> wrote:
>>
>> Oops, thats the answer to a different question but somehow = still valid
>> as you should return your connection to the pool at the end of = the
>> request.
>>
>> You could have a look at the SampleRequest/SampleApplication in = the
>> struts2 example but I have the impression that that example is = not
>> that great as I uses one connection on application level which = is not
>> what you should do on a production system.
>>
>> Maybe I can add a wicket or plain servlet example one = day...
>>
>> These are all good questions :-) might add this one to the = faq
>>
>> Rainer?
>>
>> Cheers,
>> Francis
>>
>> On Tue, Aug 24, 2010 at 12:51 AM, Francis De Brabandere
>> <francisdb@gmail.com> wrote:
>> > Open and close on each request. For higher performance = better have
>> > some kind of connection pool like c3po
>> > (http://http://sourceforge.net/projects/c3p0/) or apache = commons dbcp
>> > or whatever pooling your appserver has/supports.
>> >
>> > Cheers,
>> > Francis
>> >
>> > On Tue, Aug 24, 2010 at 12:43 AM, exxos <hatufr@gmail.com> wrote:
>> >> Hi,
>> >>
>> >> Probably a "simple" question...
>> >>
>> >> For a web application, what is preferable?
>> >>
>> >> Keeping a DBDatabase instance opened (and attached to = a driver) in the
>> >> application session (as static for example) or open = and close it each
>> >> time a
>> >> db request?
>> >>
>> >>
>> >> Regards,
>> >> exxos.
>> >>
>> >
>> >
>> >
>> > --
>> > http://www.somatik.be
>> > Microsoft gives you windows, Linux gives you the whole = house.
>> >
>>
>>
>>
>> --
>> http://www.somatik.be
>> Microsoft gives you windows, Linux gives you the whole = house.
>
>

--

http://www.somatik.be
Microsoft gives you windows, Linux gives you the whole = house.

 

------_=_NextPart_001_01CB45E3.C954A34E--