Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow setting database name when using JDBC URL #566

Closed
manikmagar opened this issue Jan 30, 2018 · 10 comments
Closed

Allow setting database name when using JDBC URL #566

manikmagar opened this issue Jan 30, 2018 · 10 comments

Comments

@manikmagar
Copy link
Contributor

As mentioned here in documentation, when using JDBC URL to initialize database, name is ignored and defaulted to test. Some times it is required to specify the database name.

Please make JDBC drivers to honor the database name set in the URL.

For example, jdbc:tc:mysql://somename:someport/library?TC_INITSCRIPT=library_db.sql should initialize a database named library and not test.

@manikmagar manikmagar changed the title Allow to set database name when using JDBC URL Allow setting database name when using JDBC URL Jan 30, 2018
@bopfermann
Copy link

+1

The only way I found around this issue was to create custom extensions of JdbcDatabaseContainer with the appropriate hard coded value.

In my case this was more or less a copy-paste of the source for MySQLContainer

Requires a custom
/META-INF/services/org.testcontainers.containers.JdbcDatabaseContainerProvider
with the fully qualified classname of your custom implementation.

@kiview
Copy link
Member

kiview commented Feb 14, 2018

Hey @bopfermann,
would you like to provide a PR implementing this feature request? 🙂

@manikmagar
Copy link
Contributor Author

I think JDBCDatabaseContainerProvider should be modified here#L10 -

public abstract JdbcDatabaseContainer newInstance(String tag, String jdbcUrl);

So, when a new container instance is acquired here, a reference of JDBC URL can be passed to the provider.

Then container providers such as MySQLContainerProvider here can utilize details from the URL and instantiate database with given name/details.

That is what is in mind for solution, Does that make sense?

@kiview
Copy link
Member

kiview commented Feb 14, 2018

Sounds like the right approach, but would be an API breaking change. Would you like to submit a PR and we look into the consequences?

@manikmagar
Copy link
Contributor Author

Yes, it breaks the API for container provider. Sure, let me give it a try and then we can verify the behavior. Thanks.

@manikmagar
Copy link
Contributor Author

Thinking out loud, how about providing an overloaded signature for newInstance method? With that, those providers who don’t need to implement this can still retain current behavior. WDYT?

@kiview
Copy link
Member

kiview commented Feb 14, 2018

And this method could have a default implementation returning newInstance(tag)?

@manikmagar
Copy link
Contributor Author

manikmagar commented Feb 26, 2018

Added a PR #594 #617 for this implementation.

@stale
Copy link

stale bot commented Oct 28, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe this is a mistake, please reply to this comment to keep it open. If there isn't one already, a PR to fix or at least reproduce the problem in a test case will always help us get back on track to tackle this.

@stale stale bot added the stale label Oct 28, 2018
@kiview
Copy link
Member

kiview commented Nov 5, 2018

Closed by #617

@kiview kiview closed this as completed Nov 5, 2018
rnorth pushed a commit that referenced this issue Mar 10, 2019
Bumps [neo4j-java-driver](https://github.com/neo4j/neo4j-java-driver) from 1.7.2 to 1.7.3.
<details>
<summary>Commits</summary>

- [`742d280`](neo4j/neo4j-java-driver@742d280) Merge pull request [#567](https://github-redirect.dependabot.com/neo4j/neo4j-java-driver/issues/567) from ali-ince/1.7-pass-access-mode
- [`49ef4db`](neo4j/neo4j-java-driver@49ef4db) Fixing wrong file header
- [`f66e194`](neo4j/neo4j-java-driver@f66e194) Merge pull request [#570](https://github-redirect.dependabot.com/neo4j/neo4j-java-driver/issues/570) from zhenlineo/1.7-flaky-test
- [`5b58956`](neo4j/neo4j-java-driver@5b58956) Fixing the flaky test that is caused by certificate file changes.
- [`f9a6fca`](neo4j/neo4j-java-driver@f9a6fca) Merge pull request [#569](https://github-redirect.dependabot.com/neo4j/neo4j-java-driver/issues/569) from michael-simons/fix-java-doc-trust-strategy
- [`bc68f0f`](neo4j/neo4j-java-driver@bc68f0f) Merge pull request [#566](https://github-redirect.dependabot.com/neo4j/neo4j-java-driver/issues/566) from zhenlineo/1.7-hostname-for-sni
- [`41949fc`](neo4j/neo4j-java-driver@41949fc) Fix JavaDoc of withTrustStrategy.
- [`227c0fc`](neo4j/neo4j-java-driver@227c0fc) Fix test failure
- [`11345c1`](neo4j/neo4j-java-driver@11345c1) Pass access mode as part of statement metadata
- [`e9e5a93`](neo4j/neo4j-java-driver@e9e5a93) Fix some test failures due to changes to routing table procedure on read-repl...
- Additional commits viewable in [compare view](neo4j/neo4j-java-driver@1.7.2...1.7.3)
</details>
<br />

[![Dependabot compatibility score](https://api.dependabot.com/badges/compatibility_score?dependency-name=org.neo4j.driver:neo4j-java-driver&package-manager=gradle&previous-version=1.7.2&new-version=1.7.3)](https://dependabot.com/compatibility-score.html?dependency-name=org.neo4j.driver:neo4j-java-driver&package-manager=gradle&previous-version=1.7.2&new-version=1.7.3)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
If all status checks pass Dependabot will automatically merge this pull request.

[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot ignore this [patch|minor|major] version` will close this PR and stop Dependabot creating any more for this minor/major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
- `@dependabot badge me` will comment on this PR with code to add a "Dependabot enabled" badge to your readme

Additionally, you can set the following in the `.dependabot/config.yml` file in this repo:
- Update frequency (including time of day and day of week)
- Automerge options (never/patch/minor, and dev/runtime dependencies)
- Pull request limits (per update run and/or open at any time)
- Out-of-range updates (receive only lockfile updates, if desired)
- Security updates (receive only security updates, if desired)

Finally, you can contact us by mentioning @dependabot.

</details>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants