spring-attic / spring-cloud-aws

All development has moved to https://github.com/awspring/spring-cloud-aws Integration for Amazon Web Services APIs with Spring
https://awspring.io/
Apache License 2.0
590 stars 376 forks source link

Add support for passing query parameters to JDBC url #679

Open jamesgustard opened 3 years ago

jamesgustard commented 3 years ago

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?

maciejwalkowiak commented 3 years ago

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.

jamesgustard commented 3 years ago

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