Reputation: 145
Can I get table name from
ResultSetMetaDataquery is join of multiple tables
example
select * from table1 , table 2
when I am going to try to retrieve table name from
ResultSetMetaDataI always founds empty value.
Note : I am using informix
driver
Upvotes: 0
Views: 1913
Reputation: 108971
Based on the Informix JDBC Guide, the driver is unable to retrieve the tablename if the query accesses more than one table and will return a single space instead:
ResultSetMetaData.getTableName()
Returns the table name for
SELECT
,INSERT
, andUPDATE
statements
SELECT
statements with more than one table name and all other statements return aString
object containing one blank space.
From: Unsupported methods and methods that behave differently
Upvotes: 1
Reputation: 27496
You should use it together with column number parameter, so try something like
String table1 = rs.getMetaData().getTableName(someColumnNumberFromFirstTable);
String table2 = rs.getMetaData().getTableName(someColumnNumberFromSecondTable);
Also see the docs.
Upvotes: 0