Fixing DB creation
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/vre-management/smart-executor@111672 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
82725241a1
commit
25516a32ba
|
@ -13,6 +13,8 @@ import java.sql.SQLException;
|
|||
import java.sql.Statement;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.gcube.smartgears.ContextProvider;
|
||||
import org.gcube.smartgears.context.application.ApplicationContext;
|
||||
import org.gcube.vremanagement.executor.plugin.PluginState;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -58,9 +60,17 @@ public class JDBCPersistenceConnector extends PersistenceConnector {
|
|||
|
||||
|
||||
try {
|
||||
String path = ".";
|
||||
ApplicationContext ctx = ContextProvider.get();
|
||||
if(ctx == null){
|
||||
Path currentAbsolutePath = Paths.get(".").toAbsolutePath().normalize();
|
||||
logger.debug(String.format("Current Absolute Path : %s",currentAbsolutePath));
|
||||
String effectiveJDBCURL = String.format("%s%s/%s", jdbcURL, currentAbsolutePath.toString(), dbName);
|
||||
path = currentAbsolutePath.toString();
|
||||
}else {
|
||||
path = ctx.application().getContextPath();
|
||||
}
|
||||
String effectiveJDBCURL = String.format("%s%s/%s", jdbcURL, path, dbName);
|
||||
logger.debug(String.format("DB URL : %s", effectiveJDBCURL));
|
||||
connection = DriverManager.getConnection(effectiveJDBCURL, username, password);
|
||||
} catch (SQLException e) {
|
||||
logger.error(String.format("Unable to connect to JDBC URL : %s", jdbcURL));
|
||||
|
|
Loading…
Reference in New Issue