对数据库信息的删除

public int delete(int id) {
		int row = 0;
		try {
			conn = getConnection();
			String sql = "delete from master where id = ?";
			stmt = conn.prepareStatement(sql);
			//索引值>0
			stmt.setInt(1,id);
			//rst = stmt.executeQuery();
			row = stmt.executeUpdate();
			//rst = stmt.executeQuery();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally {
			closeAll();
		}
		
		return row;
	}
    

 

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