Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: Java
Expertise: Beginner
May 11, 2004



Application Security Testing: An Integral Part of DevOps

Avoid SQL Exceptions when Executing the Same Query Multiple Times

When you execute the same SQL query over a hundred times, you probably get exceptions similar to this one:

java.sql.SQLException: ORA-00604: error occurred at recursive 
SQL level 1 ORA-01000: maximum open cursors exceeded
The following code shows one reason you may be getting this exception. As you can see, the same PreparedStatement/Statement is being used after each SQL query execution, and the statement is never closed:

PreparedStatement pstmt = null
for (long i=0; i<600000 i++){
 pstmt = connection.prepareStatement(...);
In order to avoid this, make the following modifications to the code:

PreparedStatement pstmt = null
for (long i=0; i<600000; i++){
 pstmt = connection.prepareStatement(...);
Ravi Naraharasetty
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date