简体   繁体   English

我可以在联接选择查询表单ResultSetMetaData中获取表名吗

[英]can i get table name in join select query form ResultSetMetaData

Can I get table name from 我可以从中获取表名吗

ResultSetMetaData
query is join of multiple tables 查询是多个表的联接

example

select * from table1 , table 2 从表1,表2中选择*

when I am going to try to retrieve table name from 当我要尝试从中检索表名称时

 ResultSetMetaData ResultSetMetaData 
I always founds empty value. 我总是发现空值。

Note : I am using informix driver 注意:我正在使用informix驱动程序

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: 基于《 Informix JDBC指南》 ,如果查询访问多个表,驱动程序将无法检索表名,而是返回一个空格:

ResultSetMetaData.getTableName()

Returns the table name for SELECT , INSERT , and UPDATE statements 返回SELECTINSERTUPDATE语句的表名

SELECT statements with more than one table name and all other statements return a String object containing one blank space. 具有多个表名的SELECT语句和所有其他语句返回包含一个空格的String对象。

From: Unsupported methods and methods that behave differently 来自: 不受支持的方法和行为不同的方法

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 . 另请参阅文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM