IDfCollection becoming null randomly
Hi All,
I am using an autoactivity in which the method at the backend hits the database and fires queries at it.I am using IDfQuery and IDfCOllection objects for this .I am using the normal procedure where we create an IDfquery object,a session and then a collection to get the results.
IDfQuery tQuery = new DfQuery();
private static IDfCollection tempColl_3 = null;
tQuery.setDQL(tData);
tempColl_3 = tQuery.execute(SESSION, DfQuery.DF_READ_QUERY);
try{
while (tempColl_3.next())
{
userName = tempColl_3.getString("user_name");
if ((usersEmail == null) || (usersEmail.equals("")))
{
usersEmail = tempColl_3.getString("user_address");
}
else
{
usersEmail +=";" + tempColl_3.getString("user_address");
}
}
//note: userName and usersEmail are variables which I have declared properly.
}
catch(Exception ee)
{
ee.printStackTrace();
}
finally{
if (tempColl_3 != null)
{
tempColl_3.close();
tempColl_3 = null;
}
}
IMP NOTE: It does not matter whether I set the tempColl_3 = null as I did in the finally block.The Nullpointer exception keeps on coming even if I remove it.
Is it something related to the database session or database connectivity.Is the connection getting timed out?There are many colections like this in my code but all have been handled properly. Kindly advise me as to why I am getting this error?
Do I need to make any config changes so that a session that I am using to fire the queries lasts longer.
Best Answer
-
Are all of your collections declared private static?
private static IDfCollection tempColl_3 = null;
This will not work very well in a multithreadded/concurrent environment as multiple calls to the method could end up with one iteration reacing the finally whilst another is in progress thus setting the tempColl_3 to null. Try changing the collection to be non static.
0
Answers
-
Hi
when this intermittent error occurs, did you notice any errors in the docbase log or in the database logs?
And when you say "becoming null randomly" , do you mena that the tempColl_3 object becomes null during the iteration? Correct?
0 -
Are all of your collections declared private static?
private static IDfCollection tempColl_3 = null;
This will not work very well in a multithreadded/concurrent environment as multiple calls to the method could end up with one iteration reacing the finally whilst another is in progress thus setting the tempColl_3 to null. Try changing the collection to be non static.
0 -
Hi Andy,
You were right.I changed all the collections and resultsets to static and it started working fine.This solution was lingering in my mind since I have a java background but was too lazy to implement it since it required changes at many places !! But it was worth the effort !!!
Thanks Vandimyovoklev too !!
0
Categories
- All Categories
- 123 Developer Announcements
- 54 Articles
- 151 General Questions
- 148 Thrust Services
- 57 OpenText Hackathon
- 37 Developer Tools
- 20.6K Analytics
- 4.2K AppWorks
- 9K Extended ECM
- 918 Core Messaging
- 84 Digital Asset Management
- 9.4K Documentum
- 32 eDOCS
- 186 Exstream
- 39.8K TeamSite
- 1.7K Web Experience Management
- 8 XM Fax
- Follow Categories