views:

24

answers:

1

Hi,

I want to pass a cursor to a stored procedure as IN parameter from my xyz.java file. I am using spring and hibernate. Can you help me with this. Needed urgently.Reply soon.

And if cannot pass then can you help with some alernative.

Thankyou.

A: 

Use Spring Stuff for calling Stored Procedure..

enter code here : public class MyStoredProcedure extends StoredProcedure {

public MyStoredProcedure(){
}
public MyStoredProcedure(DataSource ds) {
    this.setDataSource(ds);
    this.setSql("procedure name");
    this.declareParameter(new SqlParameter("param", Types.VARCHAR));
    this.compile();
}

public void callProcedure() {
    Map<String, String> inParams = new HashMap<String, String>();
    inParams.put("param", "Good");
    try {
        execute(inParams);
    } catch (Exception e) {
        System.out.println("Error Man : " + e);
    }
}


public static void main(String[] args) {
    DriverManagerDataSource dataSource new DriverManagerDataSource("Driver", "url", "uname", "upass");
    try{
    MyStoredProcedure procedure = new MyStoredProcedure(dataSource);
    procedure.callProcedure();
    }catch(Exception exception){
        System.out.println("Eroooorrror : "+exception);
    }
}

}

taher