diff --git a/.gitignore b/.gitignore index b41d5494f..ae0e15f9a 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ *.ipr *.iws out +/bin/ diff --git a/osmosis-apidb/src/main/java/org/openstreetmap/osmosis/apidb/common/DataSourceFactory.java b/osmosis-apidb/src/main/java/org/openstreetmap/osmosis/apidb/common/DataSourceFactory.java index fe0f28db2..94f91f7a8 100644 --- a/osmosis-apidb/src/main/java/org/openstreetmap/osmosis/apidb/common/DataSourceFactory.java +++ b/osmosis-apidb/src/main/java/org/openstreetmap/osmosis/apidb/common/DataSourceFactory.java @@ -34,12 +34,14 @@ public static BasicDataSource createDataSource(DatabaseLoginCredentials credenti switch (credentials.getDbType()) { case POSTGRESQL: dataSource.setDriverClassName("org.postgresql.Driver"); - dataSource.setUrl("jdbc:postgresql://" + credentials.getHost() + "/" + credentials.getDatabase() + dataSource.setUrl("jdbc:postgresql://" + credentials.getHost() + ":" + + credentials.getPort() + "/" + credentials.getDatabase() /*+ "?loglevel=2"*/); break; case MYSQL: dataSource.setDriverClassName("com.mysql.jdbc.Driver"); - dataSource.setUrl("jdbc:mysql://" + credentials.getHost() + "/" + credentials.getDatabase()); + dataSource.setUrl("jdbc:mysql://" + credentials.getHost() + ":" + + credentials.getPort() + "/" + credentials.getDatabase()); break; default: throw new OsmosisRuntimeException("Unknown database type " + credentials.getDbType() + "."); diff --git a/osmosis-apidb/src/main/java/org/openstreetmap/osmosis/apidb/common/DatabaseContext.java b/osmosis-apidb/src/main/java/org/openstreetmap/osmosis/apidb/common/DatabaseContext.java index 94990e922..23453083d 100644 --- a/osmosis-apidb/src/main/java/org/openstreetmap/osmosis/apidb/common/DatabaseContext.java +++ b/osmosis-apidb/src/main/java/org/openstreetmap/osmosis/apidb/common/DatabaseContext.java @@ -104,7 +104,8 @@ private Connection getPostgresConnection() { LOG.finer("Creating a new database connection."); newConnection = DriverManager.getConnection( - "jdbc:postgresql://" + loginCredentials.getHost() + "/" + "jdbc:postgresql://" + loginCredentials.getHost() + ":" + + loginCredentials.getPort() + "/" + loginCredentials.getDatabase(), // + "?logLevel=2" loginCredentials.getUser(), loginCredentials.getPassword() @@ -126,8 +127,10 @@ private Connection getMysqlConnection() { try { String url; - url = "jdbc:mysql://" + loginCredentials.getHost() + "/" + loginCredentials.getDatabase() + "?user=" - + loginCredentials.getUser() + "&password=" + loginCredentials.getPassword(); + url = "jdbc:mysql://" + loginCredentials.getHost() + ":" + loginCredentials.getPort() + + "/" + loginCredentials.getDatabase() + + "?user=" + loginCredentials.getUser() + + "&password=" + loginCredentials.getPassword(); if (loginCredentials.getForceUtf8()) { url += "&useUnicode=true&characterEncoding=UTF-8"; diff --git a/osmosis-apidb/src/test/java/org/openstreetmap/osmosis/apidb/v0_6/impl/DatabaseUtilities.java b/osmosis-apidb/src/test/java/org/openstreetmap/osmosis/apidb/v0_6/impl/DatabaseUtilities.java index f14e48de6..7b82cda04 100644 --- a/osmosis-apidb/src/test/java/org/openstreetmap/osmosis/apidb/v0_6/impl/DatabaseUtilities.java +++ b/osmosis-apidb/src/test/java/org/openstreetmap/osmosis/apidb/v0_6/impl/DatabaseUtilities.java @@ -44,6 +44,7 @@ public DatabaseContext createDatabaseContext() { DatabaseLoginCredentials credentials; credentials = new DatabaseLoginCredentials(DatabaseConstants.TASK_DEFAULT_HOST, + DatabaseConstants.TASK_DEFAULT_PORT, DatabaseConstants.TASK_DEFAULT_DATABASE, DatabaseConstants.TASK_DEFAULT_USER, DatabaseConstants.TASK_DEFAULT_PASSWORD, DatabaseConstants.TASK_DEFAULT_FORCE_UTF8, DatabaseConstants.TASK_DEFAULT_PROFILE_SQL, DatabaseConstants.TASK_DEFAULT_DB_TYPE); diff --git a/osmosis-core/src/main/java/org/openstreetmap/osmosis/core/database/AuthenticationPropertiesLoader.java b/osmosis-core/src/main/java/org/openstreetmap/osmosis/core/database/AuthenticationPropertiesLoader.java index 00d1ebc1a..7a90eaa09 100644 --- a/osmosis-core/src/main/java/org/openstreetmap/osmosis/core/database/AuthenticationPropertiesLoader.java +++ b/osmosis-core/src/main/java/org/openstreetmap/osmosis/core/database/AuthenticationPropertiesLoader.java @@ -14,6 +14,7 @@ * The recognised properties are: *