比如,下面这个存储过程PROCEDURE sp_hlr_sync(
I_HLR_ID      IN  NUMBER,
O_FLAG        OUT  NUMBER,
O_MSG         OUT   VARCHAR2)如何在java中分别获得 OUT 的两个值?

解决方案 »

  1.   

    try{     int age = 39;     String poetName = "dylan thomas";     CallableStatement proc = connection.prepareCall("{ call set_death_age(?, ?) }");     proc.setString(1, poetName);     proc.setInt(2, age);     cs.execute();}catch (SQLException e){ // ....} 
      

  2.   

    http://dev.csdn.net/develop/article/24/24621.shtm
      

  3.   

    public class ProcessPoetDeaths{     public abstract void sendDeath(String name, int age);}    static void mapEarlyDeaths(ProcessPoetDeaths mapper){     Connection con = null;     CallableStatement toesUp = null;     try {         con = ConnectionPool.getConnection();          con.setAutoCommit(false);          CallableStatement toesUp = connection.prepareCall("{ ? = call list_early_deaths () }");          toesUp.registerOutParameter(1, Types.OTHER);           toesUp.execute();           ResultSet rs = (ResultSet) toesUp.getObject(1);          while (rs.next()) {          String name = rs.getString(1);          int age = rs.getInt(2);         mapper.sendDeath(name, age); } rs.close(); } catch (SQLException e) { // We should protect these calls. toesUp.close(); con.close(); }}
      

  4.   

    CallableStatement a = conn.prepareCall("{?=存储过程(?)}");
            if(a == null)//取凭证序号失败
                resInsert = false;
            else{
                a.registerOutParameter(1, ""); //
                a.registerOutParameter(2, " "); //
                a.execute();
                String str = a.getString(1); //取返回值数据
    }
      

  5.   

    %ORACLE_HOME%\ora90\jdbc\demo\samples\oci8\basic-samples
    完美例子。