Closing resultSet and callableStatement

Tony

Do I have to close ResultSet and CallableStatement if I use Hibernate? For example:

CallableStatement cstmt = sessionFactory.getCurrentSession()
                .connection()
                .prepareCall("{? = call PREQUEST.GetRequestList(?,?)}");
        cstmt.registerOutParameter(1, OracleTypes.VARCHAR);
        cstmt.setString(2, sessionId);      
        cstmt.executeUpdate();
        cstmt.close(); // Closing
        return cstmt.getString(1);
Ankur Singhal

The JavaDoc for the Connection.close() method starts with "Releases this Connection object's database and JDBC resources immediately instead of waiting for them to be automatically released."

Therefore, if you close() the connection, all the acquired objects, such as Statements and ResultSets will be closed.

However, if you use connection pool, the close() method returns the connection to the pool and doesn't actually close the connection. In this case dependent objects may be left open. In this case, I think, it is better to close them manually.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Closing ResultSet but not closing PreparedStatement

From Dev

Retrieve ResultSet using CallableStatement after executeBatch()

From Dev

Closing ResultSet is must or not?

From Dev

SQL ResultSet closing suddently

From Dev

How do you get multiple resultset from a single CallableStatement?

From Dev

Closing Jena QueryEngineHTTP without closing the ResultSet

From Dev

Closing Jena QueryEngineHTTP without closing the ResultSet

From Dev

closing connection for resultset in jdbc in DAO layer

From Dev

Getting Jena Resultset after closing query - for modularity

From Dev

Apache Camel SQL component is not closing resultset?

From Dev

Getting Jena Resultset after closing query - for modularity

From Dev

Apache Camel SQL component is not closing resultset?

From Dev

error " Operation not allowed after ResultSet closed" on Mysql connection closing

From Dev

Assigning new Java Resultset object to existing one, then closing the original ResultSet object causes the newly created one to be closed?

From Dev

How to handle return ResultSet value after closing coonection in finally(Error Handling )?

From Dev

Performance Degradation on CallableStatement

From Dev

A CallableStatement was executed with nothing returned

From Dev

Execute a CallableStatement blocks the application

From Dev

A CallableStatement was executed with nothing returned

From Dev

Is CallableStatement really immune to SQL injection?

From Dev

Can CallableStatement be used in place of PreparedStatement?

From Dev

CallableStatement.getResultSet() giving null

From Dev

Java get output CallableStatement JDBC

From Dev

Is CallableStatement really immune to SQL injection?

From Dev

Mock Oracle CallableStatement.getCursor()

From Dev

Resultset within resultset

From Dev

ResultSet in Transaction

From Dev

ResultSet is Closed

From Dev

ResultSet is not updatable

Related Related

  1. 1

    Closing ResultSet but not closing PreparedStatement

  2. 2

    Retrieve ResultSet using CallableStatement after executeBatch()

  3. 3

    Closing ResultSet is must or not?

  4. 4

    SQL ResultSet closing suddently

  5. 5

    How do you get multiple resultset from a single CallableStatement?

  6. 6

    Closing Jena QueryEngineHTTP without closing the ResultSet

  7. 7

    Closing Jena QueryEngineHTTP without closing the ResultSet

  8. 8

    closing connection for resultset in jdbc in DAO layer

  9. 9

    Getting Jena Resultset after closing query - for modularity

  10. 10

    Apache Camel SQL component is not closing resultset?

  11. 11

    Getting Jena Resultset after closing query - for modularity

  12. 12

    Apache Camel SQL component is not closing resultset?

  13. 13

    error " Operation not allowed after ResultSet closed" on Mysql connection closing

  14. 14

    Assigning new Java Resultset object to existing one, then closing the original ResultSet object causes the newly created one to be closed?

  15. 15

    How to handle return ResultSet value after closing coonection in finally(Error Handling )?

  16. 16

    Performance Degradation on CallableStatement

  17. 17

    A CallableStatement was executed with nothing returned

  18. 18

    Execute a CallableStatement blocks the application

  19. 19

    A CallableStatement was executed with nothing returned

  20. 20

    Is CallableStatement really immune to SQL injection?

  21. 21

    Can CallableStatement be used in place of PreparedStatement?

  22. 22

    CallableStatement.getResultSet() giving null

  23. 23

    Java get output CallableStatement JDBC

  24. 24

    Is CallableStatement really immune to SQL injection?

  25. 25

    Mock Oracle CallableStatement.getCursor()

  26. 26

    Resultset within resultset

  27. 27

    ResultSet in Transaction

  28. 28

    ResultSet is Closed

  29. 29

    ResultSet is not updatable

HotTag

Archive