diff --git a/src/main/java/DB/Competition.java b/src/main/java/DB/Competition.java index 33c606d..7fbaeff 100644 --- a/src/main/java/DB/Competition.java +++ b/src/main/java/DB/Competition.java @@ -142,19 +142,4 @@ public class Competition extends Table { } return list; } - - @Override - public boolean save() { - return false; - } - - @Override - public boolean update() { - return false; - } - - @Override - public boolean delete() { - return false; - } } diff --git a/src/main/java/DB/DB.java b/src/main/java/DB/DB.java index 3340d8a..25a82bc 100644 --- a/src/main/java/DB/DB.java +++ b/src/main/java/DB/DB.java @@ -87,4 +87,18 @@ public class DB { } return false; } + + static public boolean delete(String table, String check, String checkValue) { + try { + PreparedStatement ps = DB.connection.prepareStatement("DELETE FROM "+table+" WHERE "+check+" = ?"); + ps.setString(1, checkValue); + int r = ps.executeUpdate(); + ps.close(); + if (r > 0) + return true; + } catch (SQLException e) { + return false; + } + return false; + } } diff --git a/src/main/java/DB/Movie.java b/src/main/java/DB/Movie.java index f1b83a4..ffc98d3 100644 --- a/src/main/java/DB/Movie.java +++ b/src/main/java/DB/Movie.java @@ -69,16 +69,6 @@ public class Movie extends Table { return list; } - @Override - public boolean save() { - return false; - } - - @Override - public boolean update() { - return false; - } - @Override public boolean delete() { return false; diff --git a/src/main/java/DB/Projection.java b/src/main/java/DB/Projection.java index 0d94513..1b89a25 100644 --- a/src/main/java/DB/Projection.java +++ b/src/main/java/DB/Projection.java @@ -63,16 +63,6 @@ public class Projection extends Table { return list; } - @Override - public boolean save() { - return false; - } - - @Override - public boolean update() { - return false; - } - @Override public boolean delete() { return false; diff --git a/src/main/java/DB/Room.java b/src/main/java/DB/Room.java index 602fc93..c9d5df4 100644 --- a/src/main/java/DB/Room.java +++ b/src/main/java/DB/Room.java @@ -65,19 +65,4 @@ public class Room extends Table { } return list; } - - @Override - public boolean save() { - return false; - } - - @Override - public boolean update() { - return false; - } - - @Override - public boolean delete() { - return false; - } } diff --git a/src/main/java/DB/Slot.java b/src/main/java/DB/Slot.java index 16c2926..9574295 100644 --- a/src/main/java/DB/Slot.java +++ b/src/main/java/DB/Slot.java @@ -46,19 +46,4 @@ public class Slot extends Table { } return list; } - - @Override - public boolean save() { - return false; - } - - @Override - public boolean update() { - return false; - } - - @Override - public boolean delete() { - return false; - } } diff --git a/src/main/java/DB/Table.java b/src/main/java/DB/Table.java index 0de08bd..9a159ca 100644 --- a/src/main/java/DB/Table.java +++ b/src/main/java/DB/Table.java @@ -5,9 +5,6 @@ public abstract class Table { static protected String tableName; static protected String check; protected String checkValue; - abstract public boolean save(); - abstract public boolean update(); - abstract public boolean delete(); protected T get(Class cl, String value) { return DB.get(cl, tableName, value, check, checkValue); @@ -16,4 +13,8 @@ public abstract class Table { protected boolean set(String value, String newValue) { return DB.set(tableName, value, newValue, check, checkValue); } + + public boolean delete() { + return DB.delete(tableName, check, checkValue); + } } diff --git a/src/main/java/DB/User.java b/src/main/java/DB/User.java index 6282de9..c6c1cb0 100644 --- a/src/main/java/DB/User.java +++ b/src/main/java/DB/User.java @@ -81,19 +81,4 @@ public class User extends Table { } return list; } - - @Override - public boolean save() { - return false; - } - - @Override - public boolean update() { - return false; - } - - @Override - public boolean delete() { - return false; - } } diff --git a/src/main/java/DB/UserType.java b/src/main/java/DB/UserType.java index 3c55ac3..d2dbb89 100644 --- a/src/main/java/DB/UserType.java +++ b/src/main/java/DB/UserType.java @@ -43,19 +43,4 @@ public class UserType extends Table { } return list; } - - @Override - public boolean save() { - return false; - } - - @Override - public boolean update() { - return false; - } - - @Override - public boolean delete() { - return false; - } } diff --git a/src/main/java/ProjectionPlanning/Main.java b/src/main/java/ProjectionPlanning/Main.java index b77eb4e..237f2a3 100644 --- a/src/main/java/ProjectionPlanning/Main.java +++ b/src/main/java/ProjectionPlanning/Main.java @@ -7,8 +7,6 @@ public class Main { public static void main(String[] args) { //new GUI(); DB.connect(); - Competition u = new Competition("Court Métrage"); - System.out.println(Competition.getAll()); - System.out.println(u.getUsers()); + System.out.println(new User("test@test.com").delete()); } }