Is it possible to provide both column name and column label in JDBC ResultSetMetadata in DB2 for queries where a real table column is not involved?
select substr('Hallo', 1) as greeting from sysibm.sysdummy1
I would like to achieve a different column label and column name for the above query.
In this case getColumnName and getColumnLabel both return the String "GREETING". I would like to set a different column label (e.g. "Begrüßung").
I use DB2 JCC4 Driver and DB2 V9. Thanks.
You can’t do that. The
columnNamein JDBC is defined as the name of the original column. ThecolumnLabelis either the original column name (i.e. same value ascolumnName) or – if specified – theASalias of the column.In your query there is only a
columnLabel(i.e.greeting). What thecolumnNameshould be in this specific case is actually implementation dependent (it might be an empty string, identical to thecolumnLabelor even something entirely different).