コード例 #1
0
  // Method for fetching all stores to drop down menu
  public void getStores() {

    // Local variables
    ResultSet rs;
    Statement stmt;
    String query = "SELECT namn FROM Butik ORDER BY namn ASC";

    try {

      stmt = con.createStatement();
      rs = stmt.executeQuery(query);

      while (rs.next()) {
        choiceBox2.getItems().add(rs.getString("namn"));
      }
      stmt.close();
    } catch (Exception e) {
      e.printStackTrace();
      System.out.println("Error fetching data");
    }
  }