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
MySQLContainer does not have getter for the databaseName field #473
In Java EE containers like Payara is JDBC pool and JDBC driver configured via properties, not URL. It is more useful to provide username, password, serverName, portName and databaseName etc. than URL.
getJdbcUrl is higher abstraction layer over it.
The problem is not about setting the test container but with using it's active configuration for the creation of the JDBC resource, this is why URL is not useful. I would like to simply use getters to configure the JDBC pool from the test container's getters but now I have to duplicate values or use sometimes getters sometimes static values. The code is inconsistent and programming not intuitive, I had to find out where can I get values I needed.
getFirstMappedPort has another implementation than getUrl uses - this is the reason why I wrote the getUrl method parsing port from the url instead (but now I see both ways give same result, ok).
It would be much more transparent to have standard JDBC getters and let user to access all useful values. Or maybe to create some transfer object for that and provide getJdbcConfiguration?.
Activity
bsideup commentedon Nov 6, 2017
Hi @dmatej,
At least in TestContainers 1.4.3, there is
getUsername,getPassword,getContainerIpAddressandgetFirstMappedPort/getExposedPort(0)for that.DB name ATM is static and has
testvalue. There is alsowithDatabaseNameto override it, but then you know it upfront :)dmatej commentedon Nov 6, 2017
The problem is not about setting the test container but with using it's active configuration for the creation of the JDBC resource, this is why URL is not useful. I would like to simply use getters to configure the JDBC pool from the test container's getters but now I have to duplicate values or use sometimes getters sometimes static values. The code is inconsistent and programming not intuitive, I had to find out where can I get values I needed.
getFirstMappedPort has another implementation than getUrl uses - this is the reason why I wrote the getUrl method parsing port from the url instead (but now I see both ways give same result, ok).
It would be much more transparent to have standard JDBC getters and let user to access all useful values. Or maybe to create some transfer object for that and provide getJdbcConfiguration?.
kiview commentedon Nov 7, 2017
@bsideup I suppose there is no damage in adding a getter for
databaseName, so we have a consistent API?add getDatabaseName to JdbcDatabaseContainer, MySQLContainer, Postgre…
add getDatabaseName to JdbcDatabaseContainer, MySQLContainer, Postgre…
Add name accessor for JDBC containers (#520)