Exemplo n.º 1
0
  /**
   * Queries all persons and shows their names.
   *
   * @param conn JDBC connection.
   * @throws SQLException In case of SQL error.
   */
  private static void queryAllPersons(Connection conn) throws SQLException {
    Statement stmt = conn.createStatement();

    ResultSet rs = stmt.executeQuery("select name from Person");

    X.println(">>> All persons:");

    while (rs.next()) X.println(">>>     " + rs.getString(1));
  }