Filed a bug report for MySQL JDBC driver

The other week, I had massive problems with one of our clients when rolling out a newer version of our software, which included JDBC driver updated from 5.1.42 to 8.0.16 (the latest at time of writing).

In order to automatically adjust tables, like adding columns, we retrieve the meta-data for a table via something like this:

    Connection conn = DriverManager.getConnection(
        "jdbc:mysql://localhost/DB", "USER", "PW");
    DatabaseMetaData meta = conn.getMetaData();
    ResultSet rs = meta.getColumns(null, null, "TABLE", null);

This works fine up to 5.1.47. However, starting with 6.0.3, this will return ALL the columns for this table across ALL the databases that this user has access to.

I’ve filed a bug report with MySQL, which also includes a minimal example to reproduce this behavior and a workaround when you have access to the code (supplying the catalog of the connection object):
  https://bugs.mysql.com/bug.php?id=95717