public static void main(String[] args) throws Exception {
    MySqlDb db = new MySqlDb();
    db.openConnection("com.mysql.jdbc.Driver", "jdbc:mysql://localhost:3306/book", "root", "admin");

    List<Map<String, Object>> records = db.findAllRecords("author");

    db.deleteRecord("author", "author_name", "slug");

    for (Map record : records) {
      System.out.println(record);
    }

    PreparedStatement pstmt = null;
    String sql = "DELETE FROM author WHERE 'author_name'='slug';";
    pstmt = db.conn.prepareStatement(sql);
    pstmt.executeUpdate();
  }
Beispiel #2
0
 public static void main(String[] args) throws Exception {
   MySqlDb db = new MySqlDb();
   db.openConnection("com.mysql.jdbc.Driver", "jdbc:mysql://localhost:3306/book", "root", "admin");
   List<Map<String, Object>> records = db.findAllRecords("author");
   for (Map record : records) {
     System.out.println(record);
   }
   db.prepDelete("author", "author_id", 1);
   db.update("author", "author_name", "Joe Schmoe", "Steve Peeve");
   //        records = db.findAllRecords("author");
   //        for(Map record : records){
   //            System.out.println(record);
   //        }
   db.closeConnection();
 }