This is a read-only copy of the MariaDB Knowledgebase generated on 2024-11-15. For the latest, interactive version please visit https://mariadb.com/kb/.

ResultSetMetaData getColumnClassName accuracy for JDBC

Hi folks,

I'm having problems getting the getColumnClassName to return the correct information. I have a sample table:

CREATE TABLE `datatypes` ( `mariadb_binary` binary(8) NULL, `mariadb_blob` blob NULL, `mariadb_boolean` tinyint(1) NULL, `mariadb_varbinary` varbinary(16) NULL, `mariadb_varchar` varchar(5) CHARACTER SET utf8 NULL, UNIQUE KEY `mariadb_serial` (`mariadb_serial`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

The ResultSetMetaData is not returning accurate GetColumnClassName information for some of the above columns:

[INFO ] 2015-03-02 09:26:52.905 [main] c.d.d.AppDbTest.main - getColumnName mariadb_binary | getColumnLabel mariadb_binary. getColumnClassName [B. getColumnDisplaySize 8. getColumnType -2. getColumnTypeName BINARY.

[INFO ] 2015-03-02 09:26:52.905 [main] c.d.d.AppDbTest.main - getColumnName mariadb_blob | getColumnLabel mariadb_blob. getColumnClassName [B. getColumnDisplaySize 65535. getColumnType -4. getColumnTypeName BLOB.

[INFO ] 2015-03-02 09:26:52.905 [main] c.d.d.AppDbTest.main - getColumnName mariadb_boolean | getColumnLabel mariadb_boolean. getColumnClassName java.lang.Boolean. getColumnDisplaySize 1. getColumnType -7. getColumnTypeName TINYINT. getPrecision 1.

[INFO ] 2015-03-02 09:26:52.998 [main] c.d.d.AppDbTest.main - getColumnName mariadb_varbinary | getColumnLabel mariadb_varbinary. getColumnClassName [B. getColumnDisplaySize 16. getColumnType -3. getColumnTypeName VARBINARY. getPrecision 16.

[INFO ] 2015-03-02 09:26:53.014 [main] c.d.d.AppDbTest.main - getColumnName mariadb_varchar | getColumnLabel mariadb_varchar. getColumnClassName java.lang.String. getColumnDisplaySize 5. getColumnType 12. getColumnTypeName VARCHAR. getPrecision 5.

Is the above by design? Is it bug within JDBC spec? I'm using MariaDB JDBC version 1.1.8.

Thanks, Tommy

Answer Answered by Georg Richter in this comment.

This is a bug. See CONJ-144.

Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.