Dan Dan - 1 year ago 86
MySQL Question

What metadata is cached when using cacheResultSetMetadata=true with MySQL JDBC connector?

I'm playing with different properties listed here, in specific with the ones marked as Performance Extensions. I'm testing with cacheResultSetMetadata, but can't find documentation on what exactly is cached when the property is set to true.

Also, is there any scenario where using it is recommended/not recommended?

Answer Source

First you have to read about ResultSetMetaData that is an object, used to get information about the types and properties of the columns in a ResultSet object.

The ResultSet object returned by a SELECT statement also contains column (field) names, lengths and types.

You can use res.getMetaData() to retrieve them into a ResultSetMetaData object, which offers the following methods to allow to get different information:

getColumnCount()              - Returns the number of columns in this ResultSet object.
getColumnName(int column)     - Get the designated column's name.
getColumnTypeName(int column) - Retrieves the designated column's database-specific type
getPrecision(int column)      - Get the designated column's specified column size.
getTableName()                - Returns the qualifier for the underlying table of the
getSchemaName()               - Returns the the designated column's table's schema name
getColumnDisplaySize()        - Returns column display length

Whether a column is read-only, nullability, automatically numbered, and so on.

Now the property cacheResultSetMetadata instruct the driver to cache ResultSetMetaData for Statements and PreparedStatements

You can also specify property metadataCacheSize that tells about the number of queries to cache ResultSetMetadata for if cacheResultSetMetaData is set to 'true' (default 50)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download