spring-cloud-aws icon indicating copy to clipboard operation
spring-cloud-aws copied to clipboard

Add support for passing query parameters to JDBC url

Open jamesgustard opened this issue 5 years ago • 2 comments

In spring boot I configure database name to have dbname?rewriteBatchedStatements=true on the end. This should append rewriteBatchedStatements=true after the database name for the postgres connection URL. When I debug it I see the ? being converted to %3F at runtime. I have tried using %3F in the database name and still get the error.

cloud.aws.rds.INSTANCE.databaseName=dbname?rewriteBatchedStatements=true

Gives: 2020-09-18 16:32:57.152 ERROR (main) [org.apache.juli.logging.DirectJDKLog] Unable to create initial connections of pool. org.postgresql.util.PSQLException: FATAL: database "dbname?rewriteBatchedStatements=true" does not exist at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2510) at org.postgresql.core.v3.QueryExecutorImpl.readStartupMessages(QueryExecutorImpl.java:2622) at org.postgresql.core.v3.QueryExecutorImpl.(QueryExecutorImpl.java:136) at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:254) at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49) at org.postgresql.jdbc.PgConnection.(PgConnection.java:211)

Is there another way to configure rewriteBatchedStatements?

jamesgustard avatar Sep 18 '20 15:09 jamesgustard

Thanks @jamesgustard for reporting. It's a bug and I couldn't find a way to pass today query parameters to JDBC url. We will work on it.

maciejwalkowiak avatar Sep 22 '20 20:09 maciejwalkowiak

Thanks , according to the postgres docs , "These properties may be specified in either the connection URL or an additional Properties object parameter to DriverManager.getConnection. The following examples illustrate the use of both methods to establish a SSL connection."

I was trying to configure the properties sent to the connection but could not find a away to access them. Being able to configure the properties would enable one to set rewriteBatchedStatements without changing the URL, this could be a possible approach.

https://jdbc.postgresql.org/documentation/94/connect.html

jamesgustard avatar Sep 23 '20 08:09 jamesgustard