java - Oracle doesn't remove cursors after closing result set and statement, while using PreparedStatement -
i facing issue in preparedstatement . open cursor count increases every time preparedstatement created , executed , not come down . closing result, statement after each execution .
make sure things not happening due other piece of code, created simple jsp , executed code .
connection connection = null; set<long> prodids = new hashset<long>(); prodids.add(5877462198l); prodids.add(782414147l); prodids.add(5547149987l); prodids.add(550424780l); prodids.add(5547045538l); prodids.add(5883926198l); prodids.add(5537432075l); prodids.add(81317072l); prodids.add(5618071249l); prodids.add(5630549908l); prodids.add(698964409l); prodids.add(822090000l); prodids.add(614679729l); prodids.add(5512339613l); prodids.add(81317068l); prodids.add(5688111900l); prodids.add(5512339611l); prodids.add(5894594380l); prodids.add(969040343l); prodids.add(827515204l); prodids.add(5626593095l); prodids.add(501511677l); prodids.add(1094656287l); prodids.add(5560791888l); prodids.add(641347103l); prodids.add(786034417l); prodids.add(774821382l); prodids.add(5599522282l); prodids.add(5591420268l); prodids.add(660541300l); prodids.add(82846941l); prodids.add(5529315772l); prodids.add(895683920l); prodids.add(5547045523l); prodids.add(801472476l); prodids.add(687163631l); prodids.add(5682795171l); prodids.add(5547045563l); prodids.add(687163630l); try { class.forname("oracle.jdbc.driver.oracledriver"); connection = datasources.getdefaultdatasource().getconnection(); out.println("connected....!!"); list<list<long>> partitionedproductidslist = lists.partition(new arraylist<long>(prodids), 1); (list<long> productidslist : partitionedproductidslist) { string sql = "select * reclassify_products_bulk_log product_id = " + productidslist.get(0); sql += "and clsf_id = ? "; preparedstatement pstmt = null; resultset rs = null; int paramindex = 1; try { pstmt = connection.preparestatement(sql); pstmt.setlong(paramindex, 203l); rs = pstmt.executequery(); while (rs.next()) { out.println(rs.getlong("product_id")); } } catch (sqlexception e) { out.println("exception : " + e.getmessage() + ""); } { jdbcutils.closequietly(rs, pstmt); } } out.println("closing connection"); } catch (exception e) { out.println("exception : " + e.getmessage() + ""); } { try { connection.close(); } catch (sqlexception e) { out.println("sqlexception : " + e.getmessage() + ""); } }
and here result query :-
select a.value, s.username, s.sid, s.serial# v$sesstat a, v$statname b, v$session s a.statistic# = b.statistic# , s.sid=a.sid , b.name = 'opened cursors current' , machine = 'v-b10' order a.value desc
initially
value username sid serial# 610 ubdb 494 1485 4 ubdb 323 16275 2 ubdb 225 41357 0 ubdb 102 14729
after loading jsp
value username sid serial# 687 ubdb 494 1485 4 ubdb 323 16275 2 ubdb 225 41357 0 ubdb 102 14729
please me , let me know if doing wrong here .
it issue in dbcp pool, using. reported in following jira ticket . https://issues.apache.org/jira/browse/dbcp-397
in case still want continue using same pool version, workaround either have parameters used in clause passed in preparedstatement or use statement in place of .
Comments
Post a Comment