In the close method of class SQLProcessor, the variable _connection is absolutely an instance of java.sql.Connection not PoolableConnection.
-----Original Message----- From: Scott Gray [mailto:scott.g...@hotwaxmedia.com] Sent: 2009年9月14日 10:44 To: user@ofbiz.apache.org Subject: Re: Do we need to manually close SQLProcesser? No the connection implementation is a PoolableConnection and closing it returns it to the pool, if you don't close it then it won't be returned until the SQLProcessor is finalized at which point it closes the connection itself. Just to reiterate in case it isn't clear, you should always call SQLProcessor.close() when you are done with it. Regards Scott On 14/09/2009, at 2:30 PM, Jack Liu wrote: > Hi, Larry > > From the constructor of class SQLProcesser, there is no need to > close it manually. > > /** > * Construct an object with an connection given. The connection > will not > * be closed by this SQLProcessor, but may be by some other. > * > * @param helperName The datasource helper (see entityengine.xml > <datasource name="..">) > * @param connection The connection to be used > */ > public SQLProcessor(String helperName, Connection connection) { > this.helperName = helperName; > this._connection = connection; > > // Do not commit while closing > if (_connection != null) { > _manualTX = false; > } > } > > > And the close method closes the true connection, not a proxy or > something else, > So if you close it by yourself, the pool will be run out. > > > > > -----Original Message----- > From: Larry.Liu [mailto:xiangqian....@wizitsoft.com] > Sent: 2009年9月14日 9:45 > To: user@ofbiz.apache.org > Subject: Re: Do we need to manually close SQLProcesser? > > Hi Gray, > > Thanks for your help, > > So according to my understanding, trying to close the SQLProcessor > will > cause available connection in the pool fewer and fewer and there > will be "No > ManagedConnections Available!" exception in the end, isn't it? > > Now we have a B2C website running on ofbiz, using Database mysql5.0 > > we only have about 2000 visitors one day, we have set the max mysql > connection to 150, in my assumption, that is enough, but it keeps on > throwing the error > "No ManagedConnections Available!" every one or two days, > > So there could be the problem of > > 1. Ofbiz out-of-the-box code leads to the connection leakage > 2. Customization code leads to the connection leakage. > > Obviously we thought the problem is in our customized code, and > SQLProcessor > is the only part where we use the connections directly. so that's > why I am > asking the question in the first mail. > > But it seems this is not the problem. > > Hope somebody can share more information about this "No > ManagedConnections > Available!" information, thanks. > > Thanks. > > Regards, > Liu Xiangqian > > Wizitsoft Information Technology Ltd. > www.wizitsoft.com | (86) 010-62670653 ext 614 > > > On Fri, Sep 11, 2009 at 10:58 AM, Scott Gray <scott.g...@hotwaxmedia.com > >wrote: > >> Hi Liu, >> >> Yes you should call close() on the SQLProcessor and no closing the >> connection will not prevent it from being returned to the pool. >> Whether it >> will solve your problem or not I don't know. >> >> Regards >> Scott >> >> HotWax Media >> http://www.hotwaxmedia.com >> >> On 11/09/2009, at 2:44 PM, Larry.Liu wrote: >> >> Hi, >>> >>> We have created SQLProcessor in our code manually and also invoke >>> >>> process.close() >>> >>> after execute the sql query or update, and we are assumpting this >>> caused >>> error of >>> >>> No ManagedConnections Available >>> >>> I have looked into the file EntitySQLProcessor.bsh, that's the >>> file for >>> webtools module SQL Processor page, I didn't see any closure of the >>> SQLProcessor. >>> >>> So here are two questions, >>> >>> 1. Do we need to manually close the SQLProcessor? >>> >>> 2. Close one SQLProcessor instance will cause the connection >>> attached to >>> this process being closed and make available connections in the >>> pool fewer >>> and fewer? >>> >>> Thanks. >>> >>> Regards, >>> Liu Xiangqian >>> >>> Wizitsoft Information Technology Ltd. >>> www.wizitsoft.com | (86) 010-62670653 ext 614 >>> >> >>