For the IBM® Data Server Driver for JDBC and SQLJ version 4.0 and later, the default behavior of ResultSetMetaData.getColumnName and ResultSetMetaData.getColumnLabel differs from the default behavior for earlier JDBC drivers. You can use the useJDBC4ColumnNameAndLabelSemantics property to change this behavior.
The following examples show the values that are returned for IBM Data Server Driver for JDBC and SQLJ Version 4.0, and for previous JDBC drivers, when the useJDBC4ColumnNameAndLabelSemantics property is not set.
CREATE TABLE MYTABLE(INTCOL INT)
SELECT MYCOL AS MYLABEL FROM MYTABLE
The following table lists the ResultSetMetaData.getColumnName and ResultSetMetaData.getColumnName values that are returned for the query:
Target data source | Behavior before IBM Data Server Driver for JDBC and SQLJ Version 4.0 | Behavior for IBM Data Server Driver for JDBC and SQLJ Version 4.0 and later | ||
---|---|---|---|---|
getColumnName value | getColumnLabel value | getColumnName value | getColumnLabel value | |
DB2® for Linux, UNIX, and Windows | MYLABEL | MYLABEL | MYCOL | MYLABEL |
IBM Informix® | MYLABEL | MYLABEL | MYCOL | MYLABEL |
DB2 for z/OS® Version 8 or later, and DB2 UDB for iSeries® V5R3 and later | MYLABEL | MYLABEL | MYCOL | MYLABEL |
DB2 for z/OS Version 7, and DB2 UDB for iSeries V5R2 | MYLABEL | MYLABEL | MYLABEL | MYLABEL |
SELECT MYCOL FROM MYTABLE
The ResultSetMetaData.getColumnName and ResultSetMetaData.getColumnLabel methods on the query return MYCOL, regardless of the target data source.
LABEL ON COLUMN MYTABLE.MYCOL IS 'LABELONCOL'
SELECT MYCOL AS MYLABEL FROM MYTABLE
The following table lists the ResultSetMetaData.getColumnName and ResultSetMetaData.getColumnName values that are returned for the query.
Target data source | Behavior before IBM Data Server Driver for JDBC and SQLJ Version 4.0 | Behavior for IBM Data Server Driver for JDBC and SQLJ Version 4.0 and later | ||
---|---|---|---|---|
getColumnName value | getColumnLabel value | getColumnName value | getColumnLabel value | |
DB2 for z/OS Version 8 or later, and DB2 UDB for iSeries V5R3 and later | MYLABEL | LABELONCOL | MYCOL | MYLABEL |
DB2 for z/OS Version 7, and DB2 UDB for iSeries V5R2 | MYLABEL | LABELONCOL | MYCOL | LABELONCOL |
LABEL ON COLUMN MYTABLE.MYCOL IS 'LABELONCOL'
SELECT MYCOL FROM MYTABLE
The following table lists the ResultSetMetaData.getColumnName and ResultSetMetaData.getColumnName values that are returned for the query.
Target data source | Behavior before IBM Data Server Driver for JDBC and SQLJ Version 4.0 | Behavior for IBM Data Server Driver for JDBC and SQLJ Version 4.0 | ||
---|---|---|---|---|
getColumnName value | getColumnLabel value | getColumnName value | getColumnLabel value | |
DB2 for z/OS Version 8 or later, and DB2 UDB for i5/OS™ V5R3 and later | MYCOL | LABELONCOL | MYCOL | MYCOL |
DB2 for z/OS Version 7, and DB2 UDB for i5/OS V5R2 | MYCOL | LABELONCOL | MYLABEL | LABELONCOL |