summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--util/src/main/kotlin/DB.kt17
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")