database #3
@@ -5,7 +5,7 @@ import java.nio.file.Path;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
public interface Database {
|
public interface Database {
|
||||||
public void connect() throws SQLException, IOException;
|
public void connect() throws SQLException;
|
||||||
public void close() throws SQLException;
|
public void close() throws SQLException;
|
||||||
public void clearDatabase() throws SQLException;
|
public void clearDatabase() throws SQLException;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,8 +7,9 @@ import java.sql.SQLException;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
public interface DatabaseManager<E> extends Database {
|
public interface DatabaseManager<E> extends Database {
|
||||||
public void saveObjects(Collection<E> objects) throws ExecutionControl.NotImplementedException, IOException, SQLException;
|
public void saveObjects(Collection<E> objects) throws SQLException;
|
||||||
public Collection<E> getObjects() throws ExecutionControl.NotImplementedException;
|
public Collection<E> getObjects() throws SQLException;
|
||||||
public void saveObject(E object) throws IOException, SQLException;
|
public void saveObject(E object) throws SQLException;
|
||||||
public E getObject(int id) throws SQLException;
|
public E getObject(int id) throws SQLException;
|
||||||
|
public void deleteObject(int id) throws SQLException;
|
||||||
}
|
}
|
||||||
@@ -48,7 +48,7 @@ public class SimpleDatabaseManager<E> implements DatabaseManager<E> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveObjects(Collection<E> objects) throws IOException, SQLException {
|
public void saveObjects(Collection<E> objects) throws SQLException {
|
||||||
for (E obj : objects) {
|
for (E obj : objects) {
|
||||||
saveObject(obj);
|
saveObject(obj);
|
||||||
}
|
}
|
||||||
@@ -56,8 +56,8 @@ public class SimpleDatabaseManager<E> implements DatabaseManager<E> {
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<E> getObjects() throws ExecutionControl.NotImplementedException {
|
public Collection<E> getObjects() throws SQLException {
|
||||||
throw new ExecutionControl.NotImplementedException("Not Implemented!");
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -103,7 +103,12 @@ public class SimpleDatabaseManager<E> implements DatabaseManager<E> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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");
|
connection = DriverManager.getConnection("jdbc:mysql://sql7.freesqldatabase.com/sql7810540?user=sql7810540&password=mXdJCFtDZz");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user