dcsimg
HOW DO I ACCESS THE CURSOR OUTPUT VALUE FROM A STORED PROCEDURE IN JAVA?
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   sundar_r
Posted On:   Saturday, April 21, 2001 12:58 PM

I am porting from informix to sql server. In informix with RESUME option he is returning the rows one by one and holds the session.

I need to pass the values of the temporary tables to the JAva application using Stored Procedure?

Thanks

Re: HOW DO I ACCESS THE CURSOR OUTPUT VALUE FROM A STORED PROCEDURE IN JAVA?

Posted By:   jon_lee  
Posted On:   Sunday, April 22, 2001 06:52 PM

Use 'registerOutParameter' method. Refer to below sample code. --- good luck ---


...


CallableStatement call = con.prepareCall( "{call sp_cursoropen (?,?,?,?,?)}");


call.registerOutParameter(1, Types.INTEGER);


call.setString(2, "select * from test_table");



call.setInt(3, 8);


call.setInt(4, 4);


call.registerOutParameter(5, Types.INTEGER);



call.executeQuery();


int id = call.getInt(1);


int size = ((Integer)call.getObject(5)).intValue();


//System.out.println(call.getObject
(5).getClass().getName());


System.out.println("cursor name: " + id);


System.out.println("total row count:" + size);


...

Re: HOW DO I ACCESS THE CURSOR OUTPUT VALUE FROM A STORED PROCEDURE IN JAVA?

Posted By:   Luigi_Viggiano  
Posted On:   Saturday, April 21, 2001 04:58 PM

The output ResultSet of a stored procedure can be obtained using executeQuery method on a CallableStatement instance.

See also Calling procedure in JDBC and CallableStatement API doc.

About | Sitemap | Contact