Question

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.

Was it helpful?

Solution

You can't do that. The columnName in JDBC is defined as the name of the original column. The columnLabel is either the original columnName or - if specified - the AS alias of the column.

In your query there is only a columnLabel (ie greeting). What the columnName should be in this specific case is actually implementation dependent (it might be an empty string, identical to the columnLabel or even something entirely different).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top