This week's book giveaway is in the Java in General forum.
We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line!
See this thread for details.
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem in getting multiple resultsets from Oracle Stored Procedure

 
sandeep pandey
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi java gurus,
I'm using Websphere 3.5 standard edition with Oracle 8i as backend. I'm trying to access multiple resultsets thru oracle stored procedure.
-----------------------------
PROCEDURE add_Person (
pPersonId IN INTEGER,
pCountry OUT tCursor,
pPerson OUT tCursor) as

BEGIN
OPEN pCountry FOR
SELECT CTRY_CODE,DESC FROM COUNTRY;
OPEN pPerson FOR
SELECT * FROM PERSONS WHERE PERSON_ID = pPersonId;
END;
END;
---------------------
This procedure works well thru Oracle DBA Studio, but when I call it thru my java program,
-------------------------
Callable Statement stmt = connection.prepareCall("{call add_person(?,?,?)}");
stmt.setInt(1, pId);
stmt.registerOutParameter(2,OracleTypes.CURSOR);
stmt.registerOutParameter(3,OracleTypes.CURSOR);
stmt.execute();
ResultSet rs = ((OracleCallableStatement)stmt).getCursor(2);
----------------------
I get a ClassCastException at runtime at last line above.
If any body has ever worked on Websphere+Oracle8i with such kinda stored procedures (returninmg multiple resulsets), pls help me out of this trouble..
Thanks for your time
sandeep
 
Salman Zaidi
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use ResultSet rs = (ResultSet)stmt.getObject(2);
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic