开发者

Spring StoredProcedure

开发者 https://www.devze.com 2023-04-13 05:53 出处:网络
Can we pass the output and input parameter to SQLParameter by index and not by name ? /* This code snippet explains data access thru CallableStatement by registering the output and input params by in

Can we pass the output and input parameter to SQLParameter by index and not by name ?

    /* This code snippet explains data access thru CallableStatement by registering the output and input params by index. */ 

    Connection conn = getConnection();
    CallableStatement sp = conn.prepar开发者_如何学编程eCall("pkg_name.proc_name");
    sp.registerOutParameter(1, oracle.jdbc.driver.OracleTypes.CURSOR);
    sp.registerOutParameter(2, oracle.jdbc.driver.OracleTypes.NUMBER);
    ResultSet rs = (ResultSet) sp.getObject(2);

Here resultset can be fetched based on index.

Please suggest.


Yes we can. Java API doc is your friend.

public void registerOutParameter(String parameterName,
                      int sqlType)
                      throws SQLException;
0

精彩评论

暂无评论...
验证码 换一张
取 消