farblog

by Malcolm Rowe

MySQL JDBC debugging: dumpMetadataOnColumnNotFound doesn’t

A short note, for the purpose of seeding Google1 with some useful information:

If you find yourself trying to debug why MySQL’s JDBC driver might be raising a “Column ‘e.Name’ not found” exception resulting from a call to ResultSet.findColumn, you might look into the MySQL Connector/J configuration reference and find the interesting-looking dumpMetadataOnColumnNotFound property, described therein as “Should the driver dump the field-level metadata of a result set into the exception message when ResultSet.findColumn() fails?”

The documentation says that this property is available “since version 3.1.13”.

The documentation lies.

It turns out that dumpMetadataOnColumnNotFound was introduced in Connector/J 3.1.13, but only to the 3.1.x branch — it doesn’t appear that it made it into any later version in any other branch.

As to why you might be running into this problem in the first place: it looks like there was a bug / change in behaviour (delete as appropriate) introduced in either MySQL server 5.something or Connector/J 5.something (details are unclear) such that after issuing a query like this:

SELECT a1.col1 AS data FROM TableA AS a1, TableA AS a2

calling ResultSet.getString("a1.col1") no longer works — in this case, you need to use ResultSet.getString("col1"), but the right column name to use differs depending on the original query: in some cases the first option might be correct!

I think this problem is the same as reported in MySQL bugs #35610 and/or #35150, but it’s hard to tell exactly what’s going on.

Did I mention how much I dislike MySQL recently?


  1. Other search engines are available.