flyway: No "current" schema in flyway.url causes a Flyway exception

Using the Maven plugin, with a Mysql JDBC url containing no schema, Flyway migrates the database, but fails just after complaining with “Error setting current schema to ``: No database selected”.

Failing Jdbc url : jdbc:mysql://localhost:3306 Valid Jdbc url : jdbc:mysql://localhost:3306/myDatabase

This occurs even with some schemas specified (in the pom.xml),

Not reproduced with Flyway 2.1.1 (maven 3.0.5) Failing with Flyway plugin : 2.2.1 (maven 3.1) Driver : org.gjt.mm.mysql.Driver

It seems that this line in Flyway.java (https://github.com/flyway/flyway/blob/master/flyway-core/src/main/java/com/googlecode/flyway/core/Flyway.java#L875) assumes that dbSupport.getCurrentSchema() will return something meaningful but it returns an empty string the failing jdbc url.

About this issue

  • Original URL
  • State: closed
  • Created 11 years ago
  • Comments: 22 (4 by maintainers)

Commits related to this issue

Most upvoted comments

@g0t4 @diogogmt I don’t think this is a flyway issue. login to mysql on the server with the user that flyway uses and then do: select count(*) form information_schema.events;

I bet that you’ll be getting a

ERROR 1577 (HY000): Cannot proceed because system tables used by Event Scheduler were found damaged at server start

Then you need to fix your mysql server (I haven’t found out how to do that yet). But there’s a couple of links out there

I’m still having the “no database selected” problem with Flyway 4.2.0 and running Flyway through Gradle. The flyway.url is set without the schema name, while flyway.schemas is set to the correct schema name. This did not happen with Flyway 3.2.1.

I have to workaround this by putting the schema name in the URL, however I would prefer to avoid this. Any suggestion?

Cannot proceed because system tables used by Event Scheduler were found damaged at server start - seems like a different issue?

On Wed, Sep 16, 2015 at 5:07 PM, Diogo Monteiro notifications@github.com wrote:

Having similar issues:

org.flywaydb.core.api.FlywayException: Unable to check whether schema sphereds is empty at org.flywaydb.core.internal.dbsupport.Schema.empty(Schema.java:95) at org.flywaydb.core.Flyway$1.execute(Flyway.java:1021) at org.flywaydb.core.Flyway$1.execute(Flyway.java:1006) at org.flywaydb.core.Flyway.execute(Flyway.java:1418) at org.flywaydb.core.Flyway.migrate(Flyway.java:1006) at com.clouddynamics.exosphere.platform.flyway.FlywayService.migrate(FlywayService.java:81) at com.clouddynamics.exosphere.platform.common.init.ServiceContainerStartupManager.initializeResources(ServiceContainerStartupManager.java:34) at com.clouddynamics.exosphere.platform.common.init.ExosphereServiceContainerListener.contextInitialized(ExosphereServiceContainerListener.java:35) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4728) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5166) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717) at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:940) at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1738) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) Caused by: java.sql.SQLException: Cannot proceed because system tables used by Event Scheduler were found damaged at server start at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1094) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4226) at com.mysql.jdbc.MysqlIO.nextRowFast(MysqlIO.java:2188) at com.mysql.jdbc.MysqlIO.nextRow(MysqlIO.java:2044) at com.mysql.jdbc.MysqlIO.readSingleRowSet(MysqlIO.java:3538) at com.mysql.jdbc.MysqlIO.getResultSet(MysqlIO.java:489) at com.mysql.jdbc.MysqlIO.readResultsForQueryOrUpdate(MysqlIO.java:3240) at com.mysql.jdbc.MysqlIO.readAllResults(MysqlIO.java:2411) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2834) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2840) at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2082) at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2212) at org.flywaydb.core.internal.dbsupport.JdbcTemplate.queryForInt(JdbcTemplate.java:156) at org.flywaydb.core.internal.dbsupport.mysql.MySQLSchema.doEmpty(MySQLSchema.java:49) at org.flywaydb.core.internal.dbsupport.Schema.empty(Schema.java:93)

Running mysql Ver 14.14 Distrib 5.6.26, for Linux (x86_64) on CentOS 7

— Reply to this email directly or view it on GitHub https://github.com/flyway/flyway/issues/598#issuecomment-140895369.