1
0
Fork 0
This repository has been archived on 2024-02-17. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
Projection_Planning/src/main/java/DB/Slot.java

64 lines
1.5 KiB
Java

package DB;
import lombok.Getter;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
public class Slot extends Table {
@Getter final private int id;
public Slot(int id) {
this.id = id;
tableName = "Slot";
check = "id";
this.checkValue = Integer.toString(this.id);
}
public Date getStartTime() {
return get(Date.class, "startTime");
}
public Competition getCompetition() {
return new Competition(get(String.class, "CompetitionName"));
}
public boolean setCompetition(Competition competition) {
return set("CompetitionName", competition.getName());
}
public boolean setStartTime(Date startTime) {
return set("startTime", startTime.toString());
}
static public ArrayList<Slot> getAll() {
ArrayList<Slot> list = new ArrayList<>();
try {
PreparedStatement ps = DB.getConnection().prepareStatement("SELECT id FROM Slot");
for (ResultSet rs = ps.executeQuery(); rs.next();)
list.add(new Slot(rs.getInt("id")));
ps.close();
} catch (SQLException | NullPointerException e) {
return null;
}
return list;
}
@Override
public boolean save() {
return false;
}
@Override
public boolean update() {
return false;
}
@Override
public boolean delete() {
return false;
}
}