• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

After deleting 14 records, application hanging

 
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello All,

As a part of my enterprise application, I have one functionality, where code selects all of the records from one table and process them one by one. If the record gets processed succesfully then application deletes this record, if not, then set the 'Processed' flag to 'NO'.

When ever I am executing this piece of code with 300 records in the table, application select all of the records and starts processing them one by one. First 14 records getting processed properly and as per the flow records are getting deleted also from the table.

When it crosses 14th record then on 15th application processed the record but after that when it tries to delete this record application just hangs. I am not sure why application is not able to delete 15th record.

If you stop the application and restart it then again application will delete first 14 records and will stop on 15th record.

Code of my delete method is as follows

<blockquote>code:
<pre name="code" class="core">
public void delete( BatchEntry batchEntry )
{
Connection _con = null;
Statement _st = null;
try
{
_con = getHibernateSession().connection();
_st = _con.createStatement();
_st.executeQuery( "Delete from BATCH_ENTRIES where ID = " + batchEntry.getId() );
_con.commit();
}
catch ( SQLException _se )
{
try
{
_con.rollback();
}
catch ( SQLException se )
{
m_log.error( "Could not rollback DB connection", se );
}
m_log.error( "SQLException while deleting record from BATCH_ENTRIES, exception is : ", _se );
throw new FitnessRuntimeException( _se );
}
finally
{
close( _st );
close( _con );
}
}

</pre>
</blockquote>


Please do let me know if you need any more information.

Thanks
[ July 16, 2008: Message edited by: Mark Spritzler ]
 
Dhananjay Inamdar
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just to add more information, on 15th time application is hanging on the following line

_st = _con.createStatement();

Of this Delete() method.

Please help me solving this problem.

Thanks in advance!
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am confused, are you opening a statement for each delete of a record? Doesn't that seem overkill. Couldn't you come up with just one statement that deletes everything that you need in one time.

Are you sure all your connections/statements are closing, because I am assuming here that you are just running out of connections/statements because it is configured to only give you so many, and since they aren't being released, then it just waits for one.

Mark
 
Dhananjay Inamdar
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mark,

Thanks for the reply!

I cann't create a statement which will delete all the required records in one shot, since this is how the nature of the application. I have to select all the records from the table and process each record one-by-one. If process is succesull then delete that single record.

BUT, after reading your reply I did review my code and find out that I am closing statement and connection but not Hibernate Session. So I did close the Hibernate Session also after connection and that thing solved my problem.

Now application is not stopping after 14th record and deleting all the processed records.

Thanks once again!!
 
If you are using a rototiller, you are doing it wrong. Even on this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic