Thread: stored procedure and java

stored procedure and java

From
Jimmy P Mani
Date:
hi all ,
i want to retrieve records from my java program

i am getting these exceptions
pls help me

No class found for refcursor
        at org.postgresql.jdbc1.AbstractJdbc1Connection.getObject(AbstractJdbc1C
onnection.java:693)
        at org.postgresql.jdbc2.AbstractJdbc2Connection.getObject(AbstractJdbc2C
onnection.java:117)
        at org.postgresql.jdbc2.AbstractJdbc2ResultSet.getObject(AbstractJdbc2Re
sultSet.java:147)
        at org.postgresql.jdbc1.AbstractJdbc1Statement.execute(AbstractJdbc1Stat
ement.java:329)
        at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Stat
ement.java:48)
        at UpdateFabric.update(UpdateFabric.java:64)
        at UpdateFabric.main(UpdateFabric.java:50)


CREATE OR REPLACE FUNCTION public.aa() RETURNS refcursor AS 'declare
entrys refcursor; begin open entrys for select mat_no,po_no from
table; return entrys; end;
'  LANGUAGE 'plpgsql' VOLATILE;

my java function is

public static void update()
     {

     try
     {

     CallableStatement s1 = con.prepareCall("{?=call aa()}");

     s1.registerOutParameter(1,Types.OTHER);

     s1.execute();
     ResultSet rs1 = (ResultSet) s1.getObject(1);

     while (rs1.next())
     {

     System.out.println((ResultSet)rs1.getObject(1));
     }
     rs1.close();
     s1.close();


     }catch(Exception e){e.printStackTrace();}


     }

my connection string is

Class.forName("org.postgresql.Driver");

Connect = DriverManager.getConnection("jdbc:postgresql://ip/db","72093701","");

------------------------------------------

is this exception is due to any problem of pgsql driver.
if so where we will get the new driver.

please help me soon
thanks in advance