I am calling an SQL procedure through Java. I am getting SQL Exception in the logs while executing my code- java.sql.SQLException: ORA-01000: maximum open cursors exceeded
I had gone through similar questions and tried this-
- increased open_cursors from 30000 to 40000.
- closed the statement in try and finally block.
But it did not solve the problem. Is something wrong with my code?
Here is my Java code-
public static void buildingHelpContent(String p_id) throws Throwable{
Connection conn = ExtractHP.getConnection();
CallableStatement cs = null;
log.debug("arguments for COMP.Help.build_hp_data p_id= "+p_id);
try {
cs = conn.prepareCall("{call COMP.Help.build_hp_data(?)}");
cs.setString(1, p_id);
cs.execute();
if(cs!=null)
cs.close();
} catch (SQLException e) {
log = ExtractHP.getLogger();
log.debug("!!! Java Exception !!!\n");
log.error("Exception while executing the procedure for ID ...."+ p_id, e);
}
finally{
if(cs!=null)
cs.close();
}
}
close
call to thefinally
block, I suggest you remove theclose
code from thetry
block. And as @user7294900 says, addif(conn!=null) conn.close();
to thefinally
block. – Bob Jarvis - Reinstate Monica