Esempio n. 1
0
  /**
   * @param args
   * @throws SQLException
   */
  public static void addPost(String nazwa, String adres, String telefon, String email)
      throws SQLException {

    Connection conn = SQLUtils.getConnection();
    String query =
        "insert into placowki (nazwa, adres, telefon, mail) values (\'"
            + nazwa
            + "\', \'"
            + adres
            + "\', \'"
            + telefon
            + "\', \'"
            + email
            + "\');";
    try (Statement st = conn.createStatement()) {
      st.executeUpdate(query);
    } catch (SQLException e) {
      System.out.println(e);
      return;
    }

    System.out.println(
        "Dodano placowke do bazy: (nazwa: "
            + nazwa
            + ", adres: "
            + adres
            + ", telefon: "
            + telefon
            + ", email: "
            + email
            + ")");
  }
Esempio n. 2
0
 public static ResultSet getPosts() throws SQLException {
   Connection conn = SQLUtils.getConnection();
   String query = "SELECT * FROM placowki;";
   Statement st = conn.createStatement();
   ResultSet rs = st.executeQuery(query);
   return rs;
 }
Esempio n. 3
0
 /**
  * @param args
  * @throws SQLException
  */
 public static void submit(String command) throws SQLException {
   Connection conn = SQLUtils.getConnection();
   try (Statement st = conn.createStatement()) {
     st.executeUpdate(command);
   } catch (SQLException e) {
     System.out.println(e);
     return;
   }
 }