libeufin

Integration and sandbox testing for FinTech APIs and data formats
Log | Files | Refs | Submodules | README | LICENSE

commit 3a6f61da1d111313b0bf74ccc1ce0f43eec00e52
parent 772d87d7969906ac14bc56791bddcc793a32dcf2
Author: Florian Dold <florian@dold.me>
Date:   Sun, 24 Sep 2023 23:43:02 +0200

pass through jdbc URIs

Diffstat:
Mutil/src/main/kotlin/DB.kt | 17++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)

diff --git 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")