1
0
Fork 0

Remove update and save function and set delete on Table

This commit is contained in:
Ethanell 2020-12-17 11:19:11 +01:00
parent 2bd9311e29
commit 694a596126
10 changed files with 19 additions and 101 deletions

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -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;

View file

@ -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;

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -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> T get(Class<T> 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);
}
}

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -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());
}
}