From: Dave Cramer <pg@fastcrypt.com>
To: Stéphane RIFF <stephane.riff@cerene.fr>
Cc: Kris Jurka <books@ejurka.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: [SPAM] - Re: [SPAM] - Re: JDBC HighLoad - Found word(s)
Date: Fri, 04 Feb 2005 09:11:00 -0500
Message-ID: <42038274.3010708@fastcrypt.com> (raw)
In-Reply-To: <42037EDD.90402@cerene.fr>
References: <41F75206.2030603@cerene.fr>
<41FA1D52.4080505@cerene.fr>
<41FA31C3.8010502@fastcrypt.com>
<41FA39D7.1070008@cerene.fr>
<Pine.BSO.4.56.0501281837510.24668@leary.csoft.net>
<41FE3906.7010008@cerene.fr>
<Pine.BSO.4.56.0501311501240.6638@leary.csoft.net>
<42032CEC.6000205@cerene.fr>
<Pine.BSO.4.56.0502040313510.15448@leary.csoft.net>
<420375C2.2020309@cerene.fr>
<42037A51.1020306@fastcrypt.com>
<42037EDD.90402@cerene.fr>
Stephane,
No.
Here is the basic usage of the connection ( regardless of the existance
of the pool)
get the connection
prepare the statement
execute the statement
do something with result
close statement
close connection ( this allows the connection to be re-used by another
request )
Having a pool does not change this pattern.
All the pool does is cache connections so that they can be re-used by
multiple threads without going through the overhead of opening the
connection.
It also minimizes the number of connections required for an application.
For example if you have 1000 requests you might only need 100
connections since they will share
the connections in the pool.
Dave
Stéphane RIFF wrote:
> I thought that preparedStatement know what connection to use even if i
> return it to the pool
>
> Dave Cramer wrote:
>
>> Stephane,
>>
>> Yes, that is true, but where do you get the connection from on the
>> next iteration of the loop ? The constructor of SQLoader.... so the
>> next loop it is gone.
>>
>> Dave
>>
>> Stéphane RIFF wrote:
>>
>>> I thought that the m_conn.close() released the connection to the
>>> pool doesn't it ?
>>> If i close the connection at the end of the loop byt a
>>> SQLoader.close() this will
>>> make one connection for each thread. I want each thread ask a
>>> connection to the pool
>>> and released it after each update.
>>>
>>> Thanks for your time
>>> Bye
>>>
>>> Kris Jurka wrote:
>>>
>>>> On Fri, 4 Feb 2005, [ISO-8859-1] St�phane RIFF wrote:
>>>>
>>>>
>>>>
>>>>> Hello,
>>>>> I implement like you said in the last post but now i get some
>>>>> errors like this :
>>>>>
>>>>> 2005-02-04 09:03:26,234 : [WARN] SQLoader - java.sql.SQLException:
>>>>> org.apache.commons.dbcp.DelegatingPreparedStatement is closed.
>>>>> I attach the two class i you want to see
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>>
>>>> Your main loop is written:
>>>>
>>>> SQLoader sl = new SQLoader();
>>>> for(int i=0;i<100;i++) {
>>>> sl.saveTrame( ... );
>>>> }
>>>>
>>>> but the end of the saveTrame method you have:
>>>>
>>>> finally {
>>>> try {
>>>> m_conn.commit();
>>>> m_conn.close();
>>>>
>>>> This closes the connection on the first iteration of the loop. I'd
>>>> suggest something like adding SQLoader.close() which gets called at
>>>> the end of the for loop.
>>>>
>>>> Kris Jurka
>>>>
>>>> ---------------------------(end of
>>>> broadcast)---------------------------
>>>> TIP 8: explain analyze is your friend
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>
>
>
>
--
Dave Cramer
http://www.postgresintl.com
519 939 0336
ICQ#14675561
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: pg@fastcrypt.com, stephane.riff@cerene.fr, books@ejurka.com
Subject: Re: [SPAM] - Re: [SPAM] - Re: JDBC HighLoad - Found word(s)
In-Reply-To: <42038274.3010708@fastcrypt.com>
References: <41F75206.2030603@cerene.fr> <41FA1D52.4080505@cerene.fr> <41FA31C3.8010502@fastcrypt.com> <41FA39D7.1070008@cerene.fr> <Pine.BSO.4.56.0501281837510.24668@leary.csoft.net> <41FE3906.7010008@cerene.fr> <Pine.BSO.4.56.0501311501240.6638@leary.csoft.net> <42032CEC.6000205@cerene.fr> <Pine.BSO.4.56.0502040313510.15448@leary.csoft.net> <420375C2.2020309@cerene.fr> <42037A51.1020306@fastcrypt.com> <42037EDD.90402@cerene.fr> <42038274.3010708@fastcrypt.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox