database #3

Merged
Ferryry merged 11 commits from database into main 2025-12-08 18:10:08 +01:00
3 changed files with 14 additions and 8 deletions
Showing only changes of commit 995fba6fce - Show all commits

View File

@@ -5,7 +5,7 @@ import java.nio.file.Path;
import java.sql.SQLException;
public interface Database {
public void connect() throws SQLException, IOException;
public void connect() throws SQLException;
public void close() throws SQLException;
public void clearDatabase() throws SQLException;
}

View File

@@ -7,8 +7,9 @@ import java.sql.SQLException;
import java.util.Collection;
public interface DatabaseManager<E> extends Database {
public void saveObjects(Collection<E> objects) throws ExecutionControl.NotImplementedException, IOException, SQLException;
public Collection<E> getObjects() throws ExecutionControl.NotImplementedException;
public void saveObject(E object) throws IOException, SQLException;
public void saveObjects(Collection<E> objects) throws SQLException;
public Collection<E> getObjects() throws SQLException;
public void saveObject(E object) throws SQLException;
public E getObject(int id) throws SQLException;
public void deleteObject(int id) throws SQLException;
}

View File

@@ -48,7 +48,7 @@ public class SimpleDatabaseManager<E> implements DatabaseManager<E> {
}
@Override
public void saveObjects(Collection<E> objects) throws IOException, SQLException {
public void saveObjects(Collection<E> objects) throws SQLException {
for (E obj : objects) {
saveObject(obj);
}
@@ -56,8 +56,8 @@ public class SimpleDatabaseManager<E> implements DatabaseManager<E> {
@Override
public Collection<E> getObjects() throws ExecutionControl.NotImplementedException {
throw new ExecutionControl.NotImplementedException("Not Implemented!");
public Collection<E> getObjects() throws SQLException {
return null;
}
@Override
@@ -103,7 +103,12 @@ public class SimpleDatabaseManager<E> implements DatabaseManager<E> {
}
@Override
public void connect() throws SQLException, IOException {
public void deleteObject(int id) throws SQLException {
throw new SQLException("Not implemented yet");
}
@Override
public void connect() throws SQLException {
connection = DriverManager.getConnection("jdbc:mysql://sql7.freesqldatabase.com/sql7810540?user=sql7810540&password=mXdJCFtDZz");
}