Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
Database Servers
DB2InformixIngresMS SQLOraclePervasive.SQLPostgreSQLProgressSybase
Desktop Databases
FileMakerFoxProMS AccessParadox
General
General DB TopicsDatabase Theory
Related Topics
Java Development.NET DevelopmentVB DevelopmentMore Topics ...

Database Forum / DB2 Topics / December 2005

Tip: Looking for answers? Try searching our database.

ResultSet cursor is forward_only from remote SQL/PL procedure ?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
_link98@yahoo.com - 07 Dec 2005 14:24 GMT
Problem: java ResultSet cursor from SQL/PL stored-procedure is
FORWARD_ONLY.

Is it possible to have ResultSet cursors from SQL/PL procedures to
scroll forward and backwards? Perhaps I am missing something.

Environment: client UDB 8.1 FP9a on Win32, server UDB 8.1 FP9a on
Solaris 8 (64BIT).

The JDK version on the WinXP client is
java version "1.4.2_07"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_07-b05)
Java HotSpot(TM) Client VM (build 1.4.2_07-b05, mixed mode)

The ResultSet.previous()  and the ResultSet.relative() throw exceptions
saying
"This method should only be called on ResultSet objects that are
scrollable
(type TYPE_SCROLL_SENSITIVE, or TYPE_SCROLL_INSENSITIVE).

If I replace the stored-procedure call by a direct query, then the
ResultSet is scrollable both forward and backwards.
Results Sets from SQL/PL procedures are forward-only (i.e. the
Resultset.Next works fine,
but the ResultSet.relative and Resultset.previous throw exceptions.

The SQL/PL stored-procedure declares the cursor as
"WITH RETURN TO CLIENT" and also uses "FOR READ ONLY" on the query
and it makes no difference whether it is static or dynamic SQL.

Some more details below:

/* Universal Driver */
    Class.forName("com.ibm.db2.jcc.DB2Driver");
    Connection conn = DriverManager.getConnection("jdbc:db2:ods",
"u450099", PWD);
/**/

Class.forName("com.ibm.db2.jcc.DB2Driver");
 Connection conn = DriverManager.getConnection("jdbc:db2:ods",
"my_userid", PWD);

 public void doCursor(Connection conn) throws Exception {
   Statement stmt =
conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
   ResultSet rs = stmt.executeQuery("call
p_query_msg_exceptions('ownership_rule = ''M055C'' ')");
   rs.next();   ***** WORKS OK
   rs.previous();           ******* THIS THROWS EXCEPTION
   System.out.println(rs.getString(1));
   rs.close();
   stmt.close();
 }

Exception Details:

com.ibm.db2.jcc.b.SqlException: This method should only be called on
ResultSet
objects that are scrollable(type TYPE_SCROLL_SENSITIVE or
TYPE_SCROLL_INSENSITIVE)
       at com.ibm.db2.jcc.b.ad.nb(ad.java:3463)
       at com.ibm.db2.jcc.b.ad.g(ad.java:1896)
       at com.ibm.db2.jcc.b.ad.relative(ad.java:1883)
       at ProcTest.doCursor(ProcTest.java:34)
       at ProcTest.main(ProcTest.java:104)
_link98@yahoo.com - 08 Dec 2005 10:25 GMT
The symptom is identical if the SQL/PL stored procedure runs locally on
Windows,
identical error message when a Java program attempts to use
ResultSet.relative()
on the resultset from an SQL/PL procedure.

Does anyone know why there should be a scrolling difference between the
result-set from a stored-procedure and the identical result-set from a
query ?
Serge Rielau - 08 Dec 2005 13:19 GMT
> The symptom is identical if the SQL/PL stored procedure runs locally on
> Windows,
[quoted text clipped - 5 lines]
> result-set from a stored-procedure and the identical result-set from a
> query ?

That's the way it is defined and designed.

Cheers
Serge

Signature

Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab

_link98@yahoo.com - 08 Dec 2005 14:16 GMT
Damn! I cannot see that in the docs (yet).
Serge Rielau - 08 Dec 2005 15:43 GMT
> Damn! I cannot see that in the docs (yet).

Where do you find scrollable cursor information. A quick serach in
information center points towards CLI, JDBC, ....
can't see SQL Procedures anywhere...

Cheers
Serge
Signature

Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.