diff options
author | Florian Dold <florian@dold.me> | 2023-09-24 23:43:02 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2023-09-24 23:43:02 +0200 |
commit | 3a6f61da1d111313b0bf74ccc1ce0f43eec00e52 (patch) | |
tree | 88378787d49c416caf089e38731b143e9ea04a59 | |
parent | 772d87d7969906ac14bc56791bddcc793a32dcf2 (diff) | |
download | libeufin-0.9.3-dev.6.tar.gz libeufin-0.9.3-dev.6.tar.bz2 libeufin-0.9.3-dev.6.zip |
pass through jdbc URIsv0.9.3-dev.6
-rw-r--r-- | util/src/main/kotlin/DB.kt | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/util/src/main/kotlin/DB.kt b/util/src/main/kotlin/DB.kt index d79038b0..7f518ebd 100644 --- a/util/src/main/kotlin/DB.kt +++ b/util/src/main/kotlin/DB.kt @@ -267,11 +267,22 @@ fun connectWithSchema(jdbcConn: String, schemaName: String? = null) { } /** - * This function converts a postgresql://-URI to a JDBC one. - * It is only needed because JDBC strings based on Unix domain - * sockets need individual intervention. + * This function converts postgresql:// URIs to JDBC URIs. + * + * URIs that are already jdbc: URIs are passed through. + * + * This avoids the user having to create complex JDBC URIs for postgres connections. + * They are especially complex when using unix domain sockets, as they're not really + * supported natively by JDBC. */ fun getJdbcConnectionFromPg(pgConn: String): String { + if (pgConn.startsWith("postgres://")) { + throw Exception("only the postgresql:// URI scheme is supported, not postgres://") + } + // Pass through jdbc URIs. + if (pgConn.startsWith("jdbc:")) { + return pgConn + } if (!pgConn.startsWith("postgresql://") && !pgConn.startsWith("postgres://")) { logger.info("Not a Postgres connection string: $pgConn") throw Exception("Not a Postgres connection string: $pgConn") |