For the query SELECT ID AS X FROM TEST the method ResultSetMetaData.getColumnName() returns ID, I expect it to return X. Whats wrong?
This is not a bug. According the the JDBC specification, the method ResultSetMetaData.getColumnName() should return the name of the column and not the alias name. If you need the alias name, use ResultSetMetaData.getColumnLabel(). Some other database don’t work like this yet (they don’t follow the JDBC specification). If you need compatibility with those databases, use the Compatibility Mode, or set the system property h2.aliasColumnName. This also applies to DatabaseMetaData calls that return a result set. The columns in the JDBC API are column labels, not column names.
Related Questions
- After HttpSession.invalidate() is called I expect the next getSession call should return a new session with a different session id. However, it returns the same sessionid ???
- If an X-ray test returns a "not detected" result, do suppliers need to use a more accurate method to get an exact concentration?
- Where do I send products Id like to return? Please send all returns to our shipping center.