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.