[Opensource] Réf. : [Opensource] Re: [Opensource] Réf. : Re: [Opensource] isn'tit a priority to correct bugs ?

Thierry Clement Thierry.Clement at cetim.fr
Wed Nov 6 07:05:50 PST 2002


I wrote (>>) and Mike answered (>): 

>>Encouraged by Mike, I just tried again under Expresso 5.0. , connected 
>>with a MySql database, in order to try to run deeper into the causes, 
and 
>>trying to trace what happens...
>>My app uses 2 dbs : one for the tables of Expresso and one for the real 
>>data (configured with hasSetupTables=false through config file)
>
>>My app has to retrieve a lot of linked objects (in fact it handles a 
tree 
>>containing recurse nodes), hopefully with the same connection. For that, 

>>it counts on the fact that the connection of a DBObject (say the root of 
a 
>>tree) is passed through other linked nodes by building them with 
>>constructor invoked in such a way :
>>
>>linked_node = new DBNode( rootNode.getConnection() );
>
>>rootNode having been initialized by by smthg like  :
>>DBNode rootNode = DBNode.retrieveFmKey(conn, key);
>>
>>where conn is a first connection obtained by thePool.getConnection();
>>
>>the method getConnection() is a method of my specific class DBNode that 
>>returns instance var. localConnection of the inherited SecuredDBObject.
>>
>>--> Here is one pb : this variable that was never null in Expresso 4.02 
>>now can be null, so I had to modify DBNode.getConnection() in order to 
>>test it and get new connection from the pool in the case of nullity - I 
>>don't understand why this var.  localConnection gets null - may be there 

>>is a release of connection that didnt happen in 4.02 ? may be I don't 
have 
>>to rely on this variable but use another way ?

>I'm sorry, but I'm not following you on this one... could you post a 
small 
code snippet to show what can now be null that wasn't before??

See explanations at the end of this mail

>>--> there must be another pb., linked with the fact I am using one db 
for 
>>config, and one other for date, as I get the message :

>Ok, I believe I know what the source of the problem of this issue is. One 

>of the behaviors that was changed. [I forget who submitted the patch] was 

>the constructor DBObject(DBConnection)... it was changed so that the 
DBObject's data context (or dbname) was set to that of the 
>DBConnection.  For multiple independent data sources, this was indeed a 
>correct move... but now I see that it causes problem with other-db maps.

>So what I propose as a compromise would be a new constructor:

>DBObject(DBConnection, String dataContext);

>Which would be identical to the original constructor EXCEPT that the 
>DBObject's context would be that of the constructor parameter.  It would 
>require that you add these constructor's to your DBObjects, but that way, 

>we have better defined behaviors for both other-db-map and independent 
>contexts.  What do you think?

-----------------------
I think it sounds good, though is was not the point with my pb., as 
explained below

...Sorry for not answering earlier - I was on vacation and it was 
profitable as I found and solved my pb. the day I came back to work.
The cause of the pb. is mainly my fault (apologies...), but explaining it 
could be interesting to the community :

My app. displays a tree of recursive nodes, represented by a generic 
subclass Hie_Node of DBObject (in fact, types of nodes may be different, 
and I have another hierarchy of classes for that, any instance of node 
being linked to one corresponding Hie_Node).
In order to optimize the display of a tree (or subtree), I want to 
transmit a same JDBC connection to a lot of linked nodes.
I use it this way in the case of looking for child nodes of a root node: 
in a getChildren() method of my generic Node class (Hie_Node), a list of 
DBobjects is retrieved through a call to searchAndRetrieveList() :

       DBConnection theConn = getConnection();
         CtDBObject nodeListSeed = new Hie_node(theConn);
         nodeListSeed.setField("ID_HIE_NODE_SUP", getId());
         Iterator e = nodeListSeed.searchAndRetrieveList().iterator();

Expresso then automatically invokes the getThisDBObj() method of each 
object that has to be put in the list. The implementation of 
getThisDBObj() in class Hie_Node is of the form :

        public DBObject getThisDBObj() throws DBException {
        DBObject ob = new Hie_Node();
        ob.setConnection(getConnection());
        return ob;
        } /* getThisDBObj() */

the method getConnection() involved here is what Mike asked me to enlight, concerning var. 
localConnection (which is now accessible in Expresso 5.0 by getter 
getLocalConnection() ) which can now be null (I didn't observe the null 
case in Expresso 4.02) - it is defined in the "mother" class Hie_Node by :

        public DBConnection getConnection () throws DBException
        {
        DBConnection localCon = getLocalConnection();           // or 
localConnection
        if (localCon == null) {
            // following 2 lines added for use with Expresso 5.0 come from 
JDBCExecutor...
           DBConnectionPool myPool = 
DBConnectionPool.getInstance(this.getDataContext());
           localCon = myPool.getConnection(getClass().getName());
        }
            return localCon;
        }

...so that the connection I pass to the constructor of "seed node" for 
searchAndRetrieveList() is transferred from one root object to linked 
objects (here : children of the root node).

My fault was that I commented line ob.setConnection(getConnection()) in my 
implementation of getThisDBObj() because I observed getConnection() could 
return null and forgot to uncomment it after fixing the pb. of nullity.

--> consequence=  for every sub-node, a new connection had to be 
allocated, and it quicklky reached the max of available connections

Still I am confused because I suppose it should have worked even with this 
error. Indeed, I still get same type of error when using DBMaint and 
trying to list the "nodes" in the DB : I get the message :
        DBConnectionPool.java:656) - WARNING: DB Connection Pool 
'annuaire' is full even after clean.

I tried to find out why the release of connections doesn't work, but the 
code of method clean() from DBConnectionPool is not easy to debug 
(timeOuts are involved...). Does it evoke something to someone ?

Thanks

Thierry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.jcorporate.com/pipermail/opensource/attachments/20021106/b8faa739/attachment-0002.htm


More information about the Opensource mailing list