Skip to content
Snippets Groups Projects
Commit f50eef50 authored by Martin Weise's avatar Martin Weise
Browse files

closes #74

Former-commit-id: c6a738d8
parent ef1a728e
No related branches found
No related tags found
1 merge request!23Sprint results
......@@ -11,6 +11,7 @@ import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
import java.util.List;
import java.util.Optional;
......@@ -79,6 +80,7 @@ public class DatabaseService {
databaseRepository.deleteById(databaseId);
}
@Transactional
public Database create(DatabaseCreateDto createDto) throws ImageNotSupportedException, DatabaseConnectionException,
DatabaseMalformedException, ContainerNotFoundException {
log.debug("get container {}", createDto.getContainerId());
......
......@@ -31,14 +31,14 @@ public class PostgresService extends JdbcConnector {
try {
connection = open(URL, postgresProperties);
} catch (SQLException e) {
log.error("Could not connect to the database container, is it running from Docker container? IT DOES NOT WORK FROM IDE! URL: {} Params: {}", URL, postgresProperties);
log.error("Could not connect to the database container, is it running from Docker container? URL: {} Params: {}", URL, postgresProperties);
throw new DatabaseConnectionException("Could not connect to the database container, is it running?", e);
}
try {
final PreparedStatement statement = getCreateDatabaseStatement(connection, database);
statement.execute();
} catch (SQLException e) {
log.error("The SQL statement seems to contain invalid syntax");
log.error("The SQL statement seems to contain invalid syntax or database already exists");
throw new DatabaseMalformedException("The SQL statement seems to contain invalid syntax", e);
}
}
......@@ -51,14 +51,14 @@ public class PostgresService extends JdbcConnector {
try {
connection = open(URL, postgresProperties);
} catch (SQLException e) {
log.error("Could not connect to the database container, is it running from Docker container? IT DOES NOT WORK FROM IDE! URL: {} Params: {}", URL, postgresProperties);
log.error("Could not connect to the database container, is it running from Docker container? URL: {} Params: {}", URL, postgresProperties);
throw new DatabaseConnectionException("Could not connect to the database container, is it running?", e);
}
try {
final PreparedStatement statement = getDeleteDatabaseStatement(connection, database);
statement.execute();
} catch (SQLException e) {
log.error("The SQL statement seems to contain invalid syntax or already exists");
log.error("The SQL statement seems to contain invalid syntax or database does not exist");
throw new DatabaseMalformedException("The SQL statement seems to contain invalid syntax or already exists", e);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment