在网上看了不少关与java调用存储过程的帖子,多是针对oracle,而调用informix的过程按网上的方法总是失败的。 总结后得出以下调用方法: 不带返回值 public void proc() ... { try ...{ conn = getConnection(); conn.setAutoCommit(false); CallableStatement cstmt = conn.prepareCall("{call sp_test}"); ResultSet rs = cstmt.executeQuery(); rs.next(); int i = rs.getInt(1); System.out.println(i); } catch (SQLException ex) ...{ status = false; ex.printStackTrace(); log.error(ex.toString()); } finally ...{ this.closeConnection(); } } 带返回值 public void proc(String procName) ... { try ...{ conn = getConnection(); if (null == conn) ...{ status = false; return; //如果没有得到连接,返回 } CallableStatement cstmt = conn.prepareCall("{call " + procName + "()}"); cstmt.execute(); status = true; } catch (SQLException ex) ...{ status = false; log.error(ex.toString()); } finally ...{ this.closeConnection(); } }