• Post Reply Bookmark Topic Watch Topic
  • New Topic

Closing a cursor  RSS feed

 
Fred Victa
Ranch Hand
Posts: 206
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an Ibatis SQL map that contains this property:
<parameter property="my_cursor" jdbcType="CURSOR" javaType="java.sql.ResultSet" mode="OUT" resultMap="SalesResultMap" />

I have some Java code that calls a stored procedure and it gets whatever is returned from a stored procedure and sets it equal to an arraylist.
SqlSession sqlSession = null;
Map<String, Object> paramMap = new HashMap<String, Object>();

sqlSession.selectList(MyConstants.GET_SALES,paramMap);

mySales = (ArrayList) paramMap.get(MyConstants.my_cursor).get(0);

How would I close the cursor?
 
Les Morgan
Rancher
Posts: 779
19
C++ Java MySQL Database Netbeans IDE Oracle Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the case you show there, I think I would just do a sqlSession.close(), and let the dependencies clear by closing the session.
 
Fred Victa
Ranch Hand
Posts: 206
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Les Morgan wrote:In the case you show there, I think I would just do a sqlSession.close(), and let the dependencies clear by closing the session.



Does sqlSession.close() close the cursor in addition to the session?
 
Les Morgan
Rancher
Posts: 779
19
C++ Java MySQL Database Netbeans IDE Oracle Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That I cannot tell you, but the DB's will when the connection drops: all of your session dependent objects are cleaned up by the DB. Aside from that all you have to work with there is a possible MyConstants.my_cursor and you can try a close() on that, but like I said, I would just close the session and let the cleanup happen outside the app.

If you need a Ibatis specific solution, I would suggest calling them.

Fred Victa wrote:
Les Morgan wrote:In the case you show there, I think I would just do a sqlSession.close(), and let the dependencies clear by closing the session.



Does sqlSession.close() close the cursor in addition to the session?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!