You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support hikari data-source-properties in ContainerDatabaseDriver #1537
changed the title [-]ContainerDatabaseDriver ignores data-source-properties[/-][+]Support data-source-properties in ContainerDatabaseDriver[/+]on Jun 24, 2019
changed the title [-]Support data-source-properties in ContainerDatabaseDriver[/-][+]Support hikari data-source-properties in ContainerDatabaseDriver[/+]on Jun 24, 2019
Hi,
I would like to contribute and fix this issue, but, I'm not sure on the fix.
Can we agree that the modification here is to actually use info param from this method:
Update the following line of code in ContainerDatabaseDriver.connect(String url, final Properties info) to create the cache URL based on (URL+Properties) instead of just URL:
// New changes to build connection string based on (URL + connection properties) instead of just using the URLfinalStringcacheUrl = buildConnectionStringCacheKey(url, info);
ConnectionUrlconnectionUrl = ConnectionUrl.newInstance(cacheUrl);
Pass in properties to JDBC connector
Method signature of JdbcDatabaseContainer.createConnection(String queryString) should get updated to JdbcDatabaseContainer.createConnection(String queryString, Properties info) in order to accept connection properties.
Merge the passed in connection properties with the temp properties created inside the function so user defined JDBC properties gets sent in to the new connection object
I'd like to work on this issue. I'll also address the related #5622. My approach would be to pass non-TC_ properties from the info parameter through to the delegate driver's connect() call. Does this sound reasonable
Looked into this. The problem is that createConnection does new Properties(info), which turns info into just default values. Those are visible through getProperty() but not through plain get(), keySet(), or entrySet(), which is how a lot of drivers and pools actually read properties. PRs 11773 and 11947 already fix it the same way.
I also wrote an end to end test with a real Postgres container and HikariCP data source properties that confirms the fix works for exactly the scenario in this issue. Happy to open a PR with it, or just add that test to one of the existing PRs instead, so we don't end up with a third duplicate attempt. Whatever works best for you.
Activity
[-]ContainerDatabaseDriver ignores data-source-properties[/-][+]Support data-source-properties in ContainerDatabaseDriver[/+][-]Support data-source-properties in ContainerDatabaseDriver[/-][+]Support hikari data-source-properties in ContainerDatabaseDriver[/+]kiview commentedon Jun 24, 2019
You are right, I changed the phrasing of the title to make this more into a feature request.
Would this be a Hikari specific feature?
bojanv55 commentedon Jun 24, 2019
AFAIK this is JDBC feature.
kiview commentedon Jun 24, 2019
I don't think there is a way to set generic properties on a JDBC connection, could you point me to the documentation?
Also this is a Spring-Boot-Hikari specific thing IMO, so maybe we should check in the Spring-Boot code what happens with the Hikari object etc.
bojanv55 commentedon Jun 24, 2019
smth like this?
kiview commentedon Jun 25, 2019
Oh you are right, great.
We should be able to use this somehow:
https://docs.oracle.com/javase/8/docs/api/java/sql/DriverManager.html#getConnection-java.lang.String-java.util.Properties-
glefloch commentedon Aug 28, 2019
Hi,
I would like to contribute and fix this issue, but, I'm not sure on the fix.
Can we agree that the modification here is to actually use
infoparam from this method:testcontainers-java/modules/jdbc/src/main/java/org/testcontainers/jdbc/ContainerDatabaseDriver.java
Line 64 in 0044218
into that call :
testcontainers-java/modules/jdbc/src/main/java/org/testcontainers/jdbc/ContainerDatabaseDriver.java
Line 124 in 0044218
which means updating this method signature (or adding a new one) to accept
Properties infoand mergeusernameandpasswordto it:testcontainers-java/modules/jdbc/src/main/java/org/testcontainers/containers/JdbcDatabaseContainer.java
Lines 185 to 188 in 0044218
Am I right?
Do you know how could I test this ?
s-jepsen commentedon Sep 2, 2022
Any progress on this?
hariohmprasath commentedon Sep 19, 2022
Hi @kiview,
We have a similar requirement and based on my understanding we need to fix this in two places:
Changes to cache URL
We need to make sure the cache URL is formed using the properties, which would a change to
ContainerDatabaseDriver.java.buildConnectionStringCacheKey()method to create the connection URL, based on URL + JDBC properties:ContainerDatabaseDriver.connect(String url, final Properties info)to create the cache URL based on (URL+Properties) instead of just URL:Pass in properties to JDBC connector
JdbcDatabaseContainer.createConnection(String queryString)should get updated toJdbcDatabaseContainer.createConnection(String queryString, Properties info)in order to accept connection properties.Let me know your thoughts and if you are fine with this approach I can work on the changes and send in a PR shortly. Thanks.
roulpriya commentedon Oct 9, 2022
Hi,
I'm willing to work on this issue.
Kamveno commentedon Sep 26, 2023
Hi, can you give me a chance to crack this?
PSW99 commentedon Apr 4, 2026
I'd like to work on this issue. I'll also address the related #5622. My approach would be to pass non-TC_ properties from the info parameter through to the delegate driver's connect() call. Does this sound reasonable
chrc commentedon Apr 29, 2026
Any progress on this?
Marcinnn123 commentedon Dec 2, 2026
Looked into this. The problem is that createConnection does new Properties(info), which turns info into just default values. Those are visible through getProperty() but not through plain get(), keySet(), or entrySet(), which is how a lot of drivers and pools actually read properties. PRs 11773 and 11947 already fix it the same way.
I also wrote an end to end test with a real Postgres container and HikariCP data source properties that confirms the fix works for exactly the scenario in this issue. Happy to open a PR with it, or just add that test to one of the existing PRs instead, so we don't end up with a third duplicate attempt. Whatever works best for you.