@Override
	public void insert(Gift gift) {
		// insert gift object into mysql. gift object only has 'title' and 'description' set.
		// get an id for gift.
		// get a dataurl for gift after the id, and update the item in mysql.
		String sql = "INSERT INTO gift " +
				"(TITLE, DESCRIP, DATAURL, OWNER, TOUCHCNT, VOTEURL) VALUES (?, ?, ?, ?, ?, ?)";
		String sqlcnt = "SELECT COUNT(*) FROM gift";
		String sqlupdate="UPDATE gift SET dataurl = ?, voteurl=? WHERE id = ?";
		
		long id = -1;
		String dataurl = null;
		String voteurl = null;
		Connection conn = null;
 
		try {
			// insert gift into mysql
			conn = dataSource.getConnection();
			PreparedStatement ps = conn.prepareStatement(sql);
			ps.setString(1, gift.getTitle());
			ps.setString(2, gift.getDescription());
			ps.setString(3, gift.getDataUrl());
			ps.setString(4, gift.getOwner());
			ps.setLong(5, gift.getTouchCount());
			ps.setString(6, gift.getVotedUserUrl());
			ps.executeUpdate();
			ps.close();
			
			// get id of the new inserted item
			ps = conn.prepareStatement(sqlcnt);
			ResultSet rs = ps.executeQuery();
			if (rs.next()) {
				id = rs.getLong(1);
				gift.setId(id);
			}
			System.out.println("insert done, gift id="+gift.getId());
			rs.close();
			ps.close();
			
			// get dataurl for this gift
			dataurl = HomeController.getGiftAbsPath(gift);
			System.out.println("dataurl="+dataurl);
			voteurl = HomeController.getVoteAbsPath(gift);
			System.out.println("voteurl="+voteurl);
			gift.setDataUrl(dataurl);
			gift.setVotedUserUrl(voteurl);
			ps = conn.prepareStatement(sqlupdate);
			ps.setString(1, dataurl);
			ps.setString(2, voteurl);
			ps.setLong(3, id);
			ps.executeUpdate();
			ps.close();
 
		} catch (SQLException e) {
			throw new RuntimeException(e);
 
		} finally {
			if (conn != null) {
				try {
					conn.close();
				} catch (SQLException e) {}
			}
		}

	}