How do I get output into Java from a SELECT stored procedure in Oracle?

Posted by Ventrue on Stack Overflow See other posts from Stack Overflow or by Ventrue
Published on 2010-05-29T04:07:19Z Indexed on 2010/05/29 4:12 UTC
Read the original article Hit count: 267

I'm using Java to connect to an Oracle 10 Database. I want to create a stored procedure (don't ask why) that takes no arguments and returns a lot of rows. Specifically, in Java I want to be able to get this data with something like:

ResultSet rs = stmt.executeQuery("call getChildless");

where getChildless is the query:

SELECT objectid
FROM Object
WHERE objectid NOT IN (SELECT parent FROM subparts);

However, I just cannot for the life of me figure out how to get my output from the stored procedure. I've googled it and I get all this sample code that Oracle won't compile, presumably it's for a previous version. Refcursors seem to come up a lot, but I'm not sure if that's what I actually want, to use it with a ResultSet.

© Stack Overflow or respective owner

Related posts about java

Related posts about Oracle