jdbc + CallableStatement +Incorrectly registered parameters



Hello I'm trying to learn how to work with stored procedures in Oracle and
java. I deal fine with ResultSets and PreparedStatement now I want to use
functions and CallableStatement.
I wrote my code looking at this sites:

http://andrej.racchvs.com/archives/2003/10/29/using-oracle-ref-cursors-in-java/
http://www.samspublishing.com/articles/article.asp?p=26251&seqNum=7
http://www.cs.bris.ac.uk/maintain/OracleDocs/java.816/a81354/samapp2.htm
http://www.enterprisedt.com/publications/oracle/result_set.html

I've created a package with a function to find buss connection between 2 cities
CREATE OR REPLACE PACKAGE cursors_pkg
AS
type dire_city_curs is record (
bus_id Bus_Schedule.bus_id%TYPE,
station_name Station.station_name%TYPE,
arrival_tim Bus_Schedule.arrival_time%TYPE,
departure_time Bus_Schedule.departure_time%TYPE,
station_nr Bus_Schedule.station_nr%TYPE);
TYPE refcursortype IS REF CURSOR return dire_city_curs;
FUNCTION getdirect(from_city varchar2, to_city varchar2) RETURN refcursortype;
END cursors_pkg;

CREATE OR REPLACE PACKAGE BODY cursors_pkg IS
FUNCTION getdirect(from_city varchar2, to_city varchar2) RETURN refcursortype
IS
mycursor refcursortype;
BEGIN
OPEN kurszor FOR
select **bla bla**
RETURN mycursor;
END;
END cursors_pkg;

now java

String usersSql = "{ call ? = cursors_pkg.getdirect(?,?) }";
CallableStatement stmt = db.prepareCall(usersSql);
stmt.registerOutParameter(1,OracleTypes.CURSOR);
stmt.setString(new String("from_city"),"London");
stmt.setString(new String("to_city"),"Paris");

stmt.execute();
ResultSet rset = (ResultSet) stmt.getObject(1);
//or ResultSet rset = ((OracleCallableStatement)stmt).getCursor (1);
while (rset.next()){
System.out.println( rset.getDouble(1) +" "+ rset.getString(2));
}
and the effect of my efforts:
SQLException: Incorrectly set or registered parameters.:null
I'm puzzled. I don't understand what goes wrong. Can you give me any hints?
I was sent to
http://www.oracle.com/technology/tech/java/sqlj_jdbc/htdocs/jdbc_faq.htm
but I find there nothing interesting.

thank you for help
.



Relevant Pages

  • Re: jdbc + CallableStatement +Incorrectly registered parameters
    ... " CREATE OR REPLACE PROCEDURE joeproc(" ... I've created a package with a function to find buss connection between 2 cities ... FUNCTION getdirect(from_city varchar2, to_city varchar2) RETURN refcursortype; ...
    (comp.lang.java.databases)
  • Re: jdbc + CallableStatement +Incorrectly registered parameters
    ... > Oracle and java. ... > I've created a package with a function to find buss connection ... > FUNCTION getdirect(from_city varchar2, to_city varchar2) RETURN ... > CallableStatement stmt = db.prepareCall; ...
    (comp.lang.java.databases)
  • Re: Writing PL/SQL in Java.
    ... public static String formatEmp ... The class Formatter has one method named formatEmp, ... CREATE OR REPLACE FUNCTION format_emp (ename VARCHAR2, ... AS LANGUAGE JAVA ...
    (comp.databases.oracle.misc)
  • Re: New B question
    ... Since Oracle 9i you can implement Java classes directly in the database ... create or replace and compile java source named foobar as ... function get_foobar(foo in varchar2) ... Have also a look at the Java Developer Guide from Oracle: ...
    (comp.lang.java.programmer)
  • Re: Oracle Java Mail Question
    ... At any rate, I am not a Java programmer, and ... do not know a lot about Java. ... The routine does not accept a header or content type. ... p_attachment_file_name in varchar2) return number ...
    (comp.databases.oracle.tools)