Beispiel #1
0
  public static void main(String[] args) throws Exception {
    IAccountDAO dao = new AccountDAOImpl();
    //		List<Account> accs =
    //				dao.findByCondition(null, null, null, null,2,5);
    //		for(Account acc : accs){
    //			System.out.println(acc.getId()+","+acc.getIdcardNo()+","+acc.getRealName());
    //		}
    //		int totalPage = dao.findTotalPage(null, null, null, null, 5);
    //		System.out.println(totalPage);

    //		dao.startAccount(1018);
    //		Account account = dao.findById(1018);
    //		System.out.println(account.getStatus());
    //		Account acc = dao.findByIdcardNo("330682196903190613");
    //		System.out.println(acc.getId());
    Account account = new Account();
    account.setEmail("*****@*****.**");
    account.setLoginName("dkfj");
    account.setIdcardNo("130281199207271123");
    account.setLoginPassword("dfad");
    account.setRealName("小米");
    account.setTelephone("41551");
    dao.addAccount(account);
  }
Beispiel #2
0
 private Account createAccount(ResultSet rs) throws Exception {
   Account a = new Account();
   a.setId(rs.getInt("id"));
   a.setRecommenderId(rs.getInt("recommender_id"));
   a.setLoginName(rs.getString("login_name"));
   a.setLoginPassword(rs.getString("login_passwd"));
   a.setStatus(rs.getString("status"));
   a.setCreateDate(rs.getDate("create_date"));
   a.setPauseDate(rs.getDate("pause_date"));
   a.setCloseDate(rs.getDate("close_date"));
   a.setRealName(rs.getString("real_name"));
   a.setIdcardNo(rs.getString("idcard_no"));
   a.setBirthdate(rs.getDate("birthdate"));
   a.setGender(rs.getString("gender"));
   a.setOccupation(rs.getString("occupation"));
   a.setTelephone(rs.getString("telephone"));
   a.setEmail(rs.getString("email"));
   a.setMailaddress(rs.getString("mailaddress"));
   a.setZipcode(rs.getString("zipcode"));
   a.setQq(rs.getString("qq"));
   a.setLastLoginTime(rs.getDate("last_login_time"));
   a.setLastLoginIp(rs.getString("last_login_ip"));
   return a;
 }
Beispiel #3
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);
    }
  }