Options

Using Flyway with the aws-mysql-jdbc driver - how to set custom driver?

Hello! I'm trying to set up Flyway to use AWS own jdbc driver for MySQL, see https://github.com/awslabs/aws-mysql-jdbc. These connection URL:s start with `jdbc:mysql:aws:`. If I use flyway-core 9.16.1 together with flyway-mysql, this works in that it will accept the URL:s and run migrations. However, it will still use the MySQL Connector/J driver. I would prefer to not have that on the classpath at all. If I don't, it fails:

   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
Tagged:

Best Answer

  • Options
    Peter_LawsPeter_Laws Posts: 215 Silver 2
    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);
    Kind regards
    Peter Laws | Redgate Software
    Have you visited our Help Center?

Answers

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file