修正一下:toesUp.registerOutParameter(1,Types.JAVA_OBJECT);该句中各种Types我都一一试了一遍,1全部无效,只有在使用 REF 类型时,报2006冲突错误.

解决方案 »

  1.   

    static void sendEarlyDeaths(PrintWriter out) {
    Connection con = null;
    CallableStatement toesUp = null;
    try {
    con = ConnectionPool.getConnection();
    // PostgreSQL needs a transaction to do this...        
    con.setAutoCommit(false);
    // Setup the call. 
    CallableStatement toesUp =
    connection.prepareCall("{ ? = call proc_int() }");
    toesUp.registerOutParameter(1, Types.OTHER);
    getResults.execute();
    ResultSet rs = (ResultSet) getResults.getObject(1);
    while (rs.next()) {
    String name = rs.getString(1);
    int age = rs.getInt(2);
    out.println(name + " was " + age + " years old.");
    }
    rs.close();
    } catch (SQLException e) {
    // We should protect these calls.        
    toesUp.close();
    con.close();
    }
    }
      

  2.   

    这段代码很常见,我也是在这段代码上修改的。
    不过,这段代码明显有错。
    例如:getResults.execute();
    我不知道去哪里得到这个方法。 ^_^
      

  3.   

    ResultSet rs = (ResultSet) getResults.getObject(1);
    这句好像有问题吧,
    一般返回应该是用getCursor方法的