public ArrayList<String> findDishsbyWindowid(Window window) throws Exception { // 搜索特定窗口下的所有菜系名称 ArrayList<String> dishs = new ArrayList<String>(); String sql = "select distinct dishname from recipe where windowid=?"; this.pstmt = this.conn.prepareStatement(sql); this.pstmt.setInt(1, window.getWindowId()); ResultSet rs = this.pstmt.executeQuery(); while (rs.next()) { dishs.add(rs.getString(1)); } return dishs; }
@Override public Recipe findRecipeIdbyWindowDishname(Window window, String dishname) throws Exception { Recipe recipe = new Recipe(); String sql = "select distinct recipeid from recipe where windowid=? and dishname=?"; this.pstmt = this.conn.prepareStatement(sql); this.pstmt.setInt(1, window.getWindowId()); this.pstmt.setString(2, dishname); ResultSet rs = this.pstmt.executeQuery(); if (rs.next()) { recipe.setRecipeId(rs.getInt(1)); // ********************************************* } // if return recipe; }