File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes DB issue (prepared statement) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "DB issue (prepared statement)" Watch "DB issue (prepared statement)" New topic
Author

DB issue (prepared statement)

Sreeharinaidu Yendluri
Greenhorn

Joined: Dec 16, 2009
Posts: 4
Hi All,

I am using TYPE_SCROLL_SENSITIVE and CONCUR_READ_ONLY to iterate through the result set object in both directions.

statement = connection.prepareStatement(query, rs.TYPE_SCROLL_SENSITIVE,rs.CONCUR_READ_ONLY);
Query: SELECT DISTINCT POL_NO, P_CODE, P_LN, MAX(EFF_DT) AS EFF_DT, T_TYP, PER_FROM,
PER_TO, BUS_TYP FROM DMGT.ARC WHERE BUS_TYP IN ('C', 'P') AND POL_NO = ?
AND (ERR_IND ! = 'X' OR ERR_IND IS NULL) GROUP BY T_TYP, PER_FROM, PER_TO,
POL_NO, P_LN, P_CODE, BUS_TYP ORDER BY EFF_DT DESC

I am able to get the data from data base DB2 in local (Windows box) but Iam faccing problem mentioned below in DEV (unix box).
Note: Both enviroments(local and dev) using same database(DB2 version 9.1) and different websphere application servers (but versions are same v6.1).we are getting the connection from the connection pooling .

Please suggest me on this and also advance thanks to all.

Error: SENSITIVE CURSOR SQL_CURLN300C1 CANNOT BE DEFINED FOR THE SPECIFIED SELECT STATEMENT

Thanks,
Sreehari.
Martin Vajsar
Sheriff

Joined: Aug 22, 2010
Posts: 3610
    
  60

I'm not experienced with DB2, but from this explanation of the error message I guess that the DEV database is obtaining the data through a different plan (storing the results in a temp table) for some reason.

Check for any difference between the two databases. I don't know how this is in DB2, but in Oracle a query plan might change for a large number of reasons:

- different indexes,
- different amount of data in table,
- different clustering factor of indexes,
- different collection of statistics (or lack of thereof),
- different system parameters,
- different architecture.

I may be mistaken; it is also possible that DB2 won't switch query plans so readily. But if it does, the feature you use (sensitive resultset) is very fragile and might stop working even after some innocuous change.
Sreeharinaidu Yendluri
Greenhorn

Joined: Dec 16, 2009
Posts: 4
Thanks for your help.

I got solution i.e. TYPE_SCROLL_INSENSITIVE
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: DB issue (prepared statement)