IDfCollection becoming null randomly

DocBuilder
DocBuilder Member
edited October 14, 2012 in Documentum #1

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

  • aflowers001
    aflowers001 Member
    edited October 8, 2012 #2 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.

Answers

  • VadimYakovlev
    VadimYakovlev Member
    edited October 8, 2012 #3

    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?

  • aflowers001
    aflowers001 Member
    edited October 8, 2012 #4 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.

  • DocBuilder
    DocBuilder Member
    edited October 14, 2012 #5

    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 !!