Announcement Announcement Module
No announcement yet.
how to call Oracle stored function fro Spring JPA DAO Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • how to call Oracle stored function fro Spring JPA DAO

    I need to call an Oracle stored procedure function within a spring JPA DAO class. I thought of obtaining Connection from Spring JPA template and execute the stored function. Now function is getting called. But it seems the connection is not geting close properly. i.e. There is a server error saying connection is not properly closed, every time I call this stored function. Can anyone help me isolate the issue. Is there a better way to call stored function within Spring JPA other than my code as folllows.

    try {
    ConnectionHandle connHandle = null;
    Connection conn = null;

    JpaTemplate jpaTemplate = getJpaTemplate();
    EntityManagerFactory entityManagerFactory = jpaTemplate
    EntityManager entityManager = entityManagerFactory

    ConnectionHandle connectionHandle = getJpaTemplate().getJpaDialect()
    .getJdbcConnection(entityManager, false);

    conn = connHandle.getConnection();
    cStmt = conn.prepareCall({? = call DCS_PKG_FLIGHT_SCHEDULE.dcs_f_flight_schedule_canc el(?) });
    cStmt.setString(C_SCHEDULE_IDS, scheduleIds);
    cStmt.registerOutParameter(C_RETURN_STATE, Types.VARCHAR);

    returnObj = cStmt.getString(C_RETURN_STATE);

    }catch (...)
    }finally (

    if (cStmt != null) {
    try {
    } catch (Exception cStmtExc) {
    log.error("Exception occurred when closing the callable statement." + cStmtExc.getMessage());

    if (conn != null) {
    try {
    } catch (Exception connExc) {
    log.error("Exception occurred when closing the connection." + connExc.getMessage());