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

closes #74

Former-commit-id: 0a128b3a
parent 64d16013
Branches
Tags
1 merge request!23Sprint results
...@@ -11,6 +11,7 @@ import lombok.extern.log4j.Log4j2; ...@@ -11,6 +11,7 @@ import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
...@@ -79,6 +80,7 @@ public class DatabaseService { ...@@ -79,6 +80,7 @@ public class DatabaseService {
databaseRepository.deleteById(databaseId); databaseRepository.deleteById(databaseId);
} }
@Transactional
public Database create(DatabaseCreateDto createDto) throws ImageNotSupportedException, DatabaseConnectionException, public Database create(DatabaseCreateDto createDto) throws ImageNotSupportedException, DatabaseConnectionException,
DatabaseMalformedException, ContainerNotFoundException { DatabaseMalformedException, ContainerNotFoundException {
log.debug("get container {}", createDto.getContainerId()); log.debug("get container {}", createDto.getContainerId());
......
...@@ -31,14 +31,14 @@ public class PostgresService extends JdbcConnector { ...@@ -31,14 +31,14 @@ public class PostgresService extends JdbcConnector {
try { try {
connection = open(URL, postgresProperties); connection = open(URL, postgresProperties);
} catch (SQLException e) { } 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); throw new DatabaseConnectionException("Could not connect to the database container, is it running?", e);
} }
try { try {
final PreparedStatement statement = getCreateDatabaseStatement(connection, database); final PreparedStatement statement = getCreateDatabaseStatement(connection, database);
statement.execute(); statement.execute();
} catch (SQLException e) { } 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); throw new DatabaseMalformedException("The SQL statement seems to contain invalid syntax", e);
} }
} }
...@@ -51,14 +51,14 @@ public class PostgresService extends JdbcConnector { ...@@ -51,14 +51,14 @@ public class PostgresService extends JdbcConnector {
try { try {
connection = open(URL, postgresProperties); connection = open(URL, postgresProperties);
} catch (SQLException e) { } 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); throw new DatabaseConnectionException("Could not connect to the database container, is it running?", e);
} }
try { try {
final PreparedStatement statement = getDeleteDatabaseStatement(connection, database); final PreparedStatement statement = getDeleteDatabaseStatement(connection, database);
statement.execute(); statement.execute();
} catch (SQLException e) { } 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); 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