Checked with ALIAS_COLUMN_NAME option, really works. It is not clear why
everything worked by default until 1.97 and now the behavior has changed.
вторник, 16 апреля 2019 г., 17:34:31 UTC+3 пользователь Aleksey
Konstantinov написал:
>
> Hi Evgenij.
>
> This query is executed on the SQuirreL SQL Client (it uses h2 JDBC driver
> version 199):
>
> [image: sqclient.jpg]
>
>
> четверг, 4 апреля 2019 г., 16:43:10 UTC+3 пользователь Evgenij Ryazanov
> написал:
>>
>> Hello.
>>
>> How exactly do you read names of aliases? I cannot reproduce this issue
>> in 1.4.197 and in other versions.
>>
>> try (Connection c = DriverManager.getConnection("jdbc:h2:mem:1"))
>> {
>> Statement s = c.createStatement();
>> s.execute("CREATE TABLE test (ID int);");
>> s.execute("INSERT INTO test (ID) VALUES (1);");
>> try (ResultSet rs = s.executeQuery("SELECT ID AS VALUE_ID
>> FROM test;")) {
>> System.out.println(rs.getMetaData().getColumnLabel(1));
>> while (rs.next()) {
>> System.out.println(rs.getInt("VALUE_ID"));
>> }
>> }
>> }
>>
>> VALUE_ID
>> 1
>>
>> It looks like you incorrectly use getColumnName(), this method returns ID
>> as expected. JDBC drivers of many databases incorrectly return name of
>> alias from this method too, but you should not expect that all databases
>> will do the same.
>>
>> H2 can emulate such behavior, you need to use a compatibility mode
>> or ALIAS_COLUMN_NAME setting.
>>
>
--
You received this message because you are subscribed to the Google Groups "H2
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.