java - ResultSet.next() is taking too much time for few records -
i'm using ojdbc(v7)
connect oracle(11g)
, in java
. in cases on big tables, resultset
can not fetch data in appropriate time.
for example output records 2, on resultset.next()
java freezes , waits long!
note1: the problem not setting fetchsize()
, rsultset.typex
, not using connection pools c3p0
, ... . i've tested of those.
note2: also when run query directly in navicat
, result shown perfectly!
getting connection method:
public connection getdbconnection() throws dbconnectionexception { connection conn = null; string connectionurl; try { class.forname("oracle.jdbc.driver.oracledriver"); conn = drivermanager.getconnection("jdbc:oracle:thin:user/pass@xxx.xxx.xxx.xxx:1521:dbname"); } catch (exception e) { e.printstacktrace(); throw new dbconnectionexception(); } return conn; }
connectiong db part:
... conn = connectionmanager.getdbconnection(); conn.setautocommit(false); string query = "{call ...(...)}"; callablestatement stmt = conn.preparecall(query,resultset.type_forward_only, resultset.concur_read_only); stmt.setfetchsize(10000); . . . stmt.registeroutparameter(x, oracletypes.cursor); stmt.execute(); resultset rs = (resultset) stmt.getobject(x); while (rs.next()) { /** problem occurs here **/ ... }
why?!
use in try catch block:
if ((cnn==null)||cnn.isclosed()){ cnn=db.getdbconnection(); //e.g. db instance of class getdbconnection() resides }
then call queries. believe somewhere in code either closing connection or connection becoming null that's why facing problem.
cheers
Comments
Post a Comment