It's possible get name of current table, on implementation of RowMapper. I try by metadata, but not have sucess
Asked
Active
Viewed 90 times
0
-
what implementation do you mean? – Rhayene Feb 12 '16 at 13:06
-
I am using the SpringData JdbcTemplate to run queries on the database, and implements the RowMapper to map the resultset – Thiago Feb 12 '16 at 13:10
-
What DB driver jar are you using? – Rainer Montag Feb 12 '16 at 13:42
-
H2 database org.h2.Drive – Thiago Feb 12 '16 at 14:09
-
Read http://www.h2database.com/html/features.html for getTableName() and check if any of the metioned conditions for getTableName() == null applies to you. – Rainer Montag Feb 12 '16 at 14:35
1 Answers
0
You can try to determine the tablename by
ResultSet.getMetaData().getTableName(int column)
As both ResultSet and ResultSetMetaData are only interfaces, the implementation depends on the database driver your are using.
So, if this method does not deliver the tablename:
- the driver implementation does not support it.
- the column does not have a table associated with (e.g. select sysdate ...)
For example current oracle db driver does not support it.
For H2, check http://www.h2database.com/html/features.html , it describes the behaviour of getTableName() depending on the selected Compatibility Mode.

Rainer Montag
- 493
- 1
- 6
- 13