X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 142618B9F8D for ; Fri, 4 Feb 2005 15:52:17 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 23935-10 for ; Fri, 4 Feb 2005 15:51:54 +0000 (GMT) Received: from net2.micro-automation.com (net2.micro-automation.com [64.7.141.29]) by svr1.postgresql.org (Postfix) with SMTP id 1311F8B9B2B for ; Fri, 4 Feb 2005 15:51:57 +0000 (GMT) Received: (qmail 2832 invoked from network); 4 Feb 2005 15:51:15 -0000 Received: from dcdsl.ebox.com (HELO ?192.168.1.36?) (davec@64.7.143.116) by net2.micro-automation.com with SMTP; 4 Feb 2005 15:51:15 -0000 Message-ID: <42039A11.5090801@fastcrypt.com> Date: Fri, 04 Feb 2005 10:51:45 -0500 From: Dave Cramer Reply-To: pg@fastcrypt.com Organization: Postgres International User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: =?UTF-8?B?U3TDqXBoYW5lIFJJRkY=?= Cc: pgsql-jdbc@postgresql.org Subject: Re: [SPAM] - Re: [SPAM] - Re: JDBC HighLoad - Found word(s) References: <41F75206.2030603@cerene.fr> <41FA1D52.4080505@cerene.fr> <41FA31C3.8010502@fastcrypt.com> <41FA39D7.1070008@cerene.fr> <41FE3906.7010008@cerene.fr> <42032CEC.6000205@cerene.fr> <420375C2.2020309@cerene.fr> <42037A51.1020306@fastcrypt.com> <42037EDD.90402@cerene.fr> <42038274.3010708@fastcrypt.com> <42039604.9000007@cerene.fr> In-Reply-To: <42039604.9000007@cerene.fr> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.047 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200502/32 X-Sequence-Number: 12212 Stephane, I didn't write the spec, I'm just explaining how to use it. Dave Stéphane RIFF wrote: > But with this usage i cannot reuse a preparedStatement. > Is it possible to create the preparedStatement in the constructor and > reused them > for each update. So that each thread has his own preparedStatements > because > each thread do an update every second, i also think that > preparedStatements > was good to use in this configuration but in your usage i have to > prepare the statement each time i get the connection. > > Dave Cramer wrote: > >> 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