Exemplo n.º 1
0
  public void addAccount(Account account) throws DAOException {
    if (account == null) {
      return;
    }
    String sql =
        "insert into account values(seq_account.nextval,?,?,?,'1',sysdate,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
    Connection conn = DBUtil.getConnection();
    try {
      conn.setAutoCommit(false);
      PreparedStatement pstmt = conn.prepareStatement(sql);
      pstmt.setObject(1, account.getRecommenderId());
      pstmt.setObject(2, account.getLoginName());
      pstmt.setObject(3, account.getLoginPassword());
      pstmt.setObject(4, account.getPauseDate());
      pstmt.setObject(5, account.getCloseDate());
      pstmt.setObject(6, account.getRealName());
      pstmt.setObject(7, account.getIdcardNo());
      pstmt.setObject(8, account.getBirthdate());
      pstmt.setObject(9, account.getGender());
      pstmt.setObject(10, account.getOccupation());
      pstmt.setObject(11, account.getTelephone());
      pstmt.setObject(12, account.getEmail());
      pstmt.setObject(13, account.getMailaddress());
      pstmt.setObject(14, account.getZipcode());
      pstmt.setObject(15, account.getQq());
      pstmt.setObject(16, account.getLastLoginTime());
      pstmt.setObject(17, account.getLastLoginIp());
      pstmt.executeUpdate();
      conn.commit();

    } catch (SQLException e) {
      try {
        conn.rollback();
      } catch (SQLException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
      }
      e.printStackTrace();
      throw new DAOException("账务账号插入失败!", e);
    }
  }