Comments
6 comments
-
Thanks for your query skagedal,
Your approach is what I'd expect, the driver configuration is the appropriate way to define this and once established there should be no need to remove the default driver as it won't be used.
Thought evidently there's some configuration complication, does yours look roughly like this?
Flyway.configure() .driver("com.mysql.cj.jdbc.Driver") .load()
-
Hi! Yes, the problem is that that code does not compile – there is no such method "driver". Here's some example output compiling that code, with Flyway 9.16.3 from Maven Central on the class path:
$ ./gradlew build > Task :app:compileJava FAILED /Users/simon/code/flyway-driver/app/src/main/java/tech/skagedal/flywaydriver/App.java:10: error: cannot find symbol Flyway.configure().driver("com.mysql.cj.jdbc.Driver"); ^ symbol: method driver(String) location: class FluentConfiguration 1 error FAILURE: Build failed with an exception.
It can also be seen by looking at the code: https://github.com/flyway/flyway/blob/main/flyway-core/src/main/java/org/flywaydb/core/api/configuration/FluentConfiguration.java – there is no `driver` method here. -
Hi! Yes, the problem is that this code does not compile – there is no method "driver" on the `FluentConfiguration` object returned by `Flyway.configure()`.
I've tested this with `flyway-core` version 9.16.3 from Maven Central, and it also matches what I see in code: https://github.com/flyway/flyway/blob/main/flyway-core/src/main/java/org/flywaydb/core/api/configuration/FluentConfiguration.java
-
Oh I see what you mean now, and that's also presumably why you were looking at the jdbcProperties parameters as a consequence on the driver comments!
Apologies, I've caught up now. While the gradle plugin would need slightly different config, since you linked the page that references such earlier I'm going to assume you allowed for that. Regardless, I'd have expected the flyway core part to work.
I'll dig into it and come back to you. -
Thanks for bearing with me Simon,
This does appear to be an oversight on our part, I've raised a request to get it looked at, as it presently stands our documentation is misleading.
As a work around, you could address the underlying object via ClassicConfiguration the same way the FluentConfiguration typically would, it lacks some of the nicety, but should allow you to progress.E.G
ClassicConfiguration config = new ClassicConfiguration(); config.setUrl("jdbc:h2:mem:db"); config.setUser("sa"); config.setDriver("org.amazon.aura.Driver"); Flyway flyway = new Flyway(config);
-
Ah, thanks a lot Peter! I'll give that a try!
Add comment
Please sign in to leave a comment.
org.flywaydb.core.api.FlywayException: Unable to instantiate JDBC driver: com.mysql.cj.jdbc.Driver => Check whether the jar file is present
So I've been trying to set the driver to the aws-jdbc-sql one, using the method described here: https://documentation.red-gate.com/fd/driver-184127498.html
However, there exists no method "driver" on the FluentConfiguration object returned by Flyway.configure(). It also doesn't seem to respect if try to set it through Java properties.
Is there a way to make this work?
Regards, Simon