Override JDBC url?
chrisknoll opened this issue · 4 comments
In our environment, we have JDBC drivers registered to handle Redshift and Postgresql.
There are problems with using the RedShift driver to connect to a PG instance, and so there's a parameter you can apply to a JDBC url where the RedShift driver will ignore it and let the other PG driver handle the connection. That parameter is shown here.
I'd like to add the paramater OpenSourceSubProtocolOverride=true
in my JDBC url to connect to the embedded database, however I don't see how I can override it when I make my call to
protected static DataSource getDataSource() {
return pg.getEmbeddedPostgres().getPostgresDatabase();
}
...
...
jdbcTemplate = new JdbcTemplate(getDataSource());
I'd like to configure the JDBC url that's used in the pg.getEmbeddedPostgres().getPostgresDatabase()
call.
Is that possible?
You could easily:
- Call getDataSource with a map of datasource properrties
OR - Override getJDBCUrl
I believe either will work for you.
I'm sorry, I'm not quite following. If I did modify getDatasource to pass in a map ie:
protected static DataSource getDataSource(Map jdbcParams) {
return pg.getEmbeddedPostgres().getPostgresDatabase();
}
Where can I use those mapped properties within the call:
pg.getEmbeddedPostgres().getPostgresDatabase();
As some additional context, I'm gettign the pg
instance via the SingleInstancePostgresRule, so getting access to the underlying JDBC connection seems a bit encapsulated. Would you suggest extending that rule to support passing in the paramaters? And if so, my question remains: where do I go to take the custom JDBC params and pass it into the underlying connection?
I found a reference to a builderCustomizer
that I can pass into the SingleInstancePostgrtesRule constructor...would this be a mechanism to alter how the instance is connected to?
Note: It is dangerous in 1.0.0 to build your own URL but you can do so given getHost and get Port are exposed. I beleive that resolves the matter.