就是原来用sql封装好的Bean不用改

解决方案 »

  1.   

    CallableStatement cStmt = conn.prepareCall("{call REPORT_EFFORT_SUMMARY(?,?,?,?,?) }");其中: Connection conn;
    "REPORT_EFFORT_SUMMARY " 是我的存储过程名
      

  2.   

    select 语句是用PrepareStatement , 存储过程要用CallableStatement. 
    给你一段代码:
    public void execProcedure(String subscriber, String user,
           Timestamp  startDate, Timestamp endDate, Timestamp newVersion )
           throws ETMDataAccessException {        SQLConnectionManager manager = null;
            Connection conn = null;
            CallableStatement cStmt = null;        boolean commit = false;
            try {
                manager = SQLConnectionManager.getInstance();
                conn = manager.getConnection();
                cStmt = conn.prepareCall("{call REPORT_EFFORT_SUMMARY(?,?,?,?,?) }");
                cStmt.setTimestamp(1, startDate);
                cStmt.setTimestamp(2, endDate);
                cStmt.setString(3, subscriber);
                cStmt.setString(4, user);
                cStmt.setTimestamp(5, newVersion);
                boolean bRight = cStmt.execute();
    //if (bRight != true) {
                  //      throw new SQLException();
    //            }
                commit = true;
            } catch (SQLException e) {
                throw new ETMDataAccessException(e);
            } catch (ETMInitializationException e) {
                throw new ETMDataAccessException(e);
            } finally {
                try {
                  if (commit) {
                      conn.commit();
                  } else {
                      conn.rollback();
                  }             
                } catch (Exception e) {
                        throw new ETMDataAccessException(e);
                } finally {
                    if (cStmt != null) {
                        try {
                            cStmt.close();
                        } catch (Exception e) {}
                    }           
                    if (manager != null) {
                        manager.releaseConnection(conn);
                    }
                }
            }
          //  return commit;
        }