对数据库的添加操作

public int insert(Master master) {
		int row = 0;
		try {
			conn = getConnection();
			String sql = "insert into master values(?,?,?)";
		    stmt = conn.prepareStatement(sql);
			stmt.setString(1,master.getName());
			stmt.setString(2,master.getPassword());
			stmt.setInt(3, master.getMoney());
		    row = stmt.executeUpdate();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally {
			closeAll();
		}
		return row;
	}
    

 

你可能感兴趣的:(数据库的基本操作)