View Single Post
  (#1 (permalink)) Old
yanhua yanhua is offline
Member
 
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Join Date: Feb 2008
Default PreparedStatement slow down the query execution? - 09-08-2008, 08:17 AM

Hi,

I got a problem during execute a sql.

I used the jdbc thin driver to connect to my oracle DB.

In my code, it looks like this

PreparedStatement oStmt = null;
oStmt = oCon.getConnection().prepareStatement(sQry, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);

if (!sMetaQuery.equals("")) {
oStmt.setString(1, StringUtils.toUpperCase(sMeta) + "%");
}

oStmt.setFetchSize(nMaxRows);
oStmt.setFetchDirection(ResultSet.FETCH_FORWARD);
oStmt.setString(1, sPartialKN);
oRS = oStmt.executeQuery();


The query is just something with join clause and some condition checks. when the program comes to call execute() method, it will take a quite long time (several minutes) to get the result. But when I directly run this query from some sql client it will only take several seconds.

Can some one help me to solve this probem?

Thanks and kind regards,

Hua
Reply With Quote