DatabaseMetaData.getColumns返回同义词的空ResultSet [英] DatabaseMetaData.getColumns returning an empty ResultSet for synonyms
问题描述
元数据上的方法 getColumns()
返回一个空的ResultSet用于同义词(对于表和视图,它正确地返回列列表)。
The method getColumns()
on the metadata is returning an empty ResultSet for Synonyms (for tables and views it's returning the list of columns properly).
这种情况发生在Oracle 11g Express上并使用最新的Oracle JDBC驱动程序(11.2.3)。
This happens on Oracle 11g Express and using the latest Oracle JDBC driver (11.2.3).
其他SQL是否会发生这种情况服务器呢?
Does this happen for other SQL servers too?
欢迎任何解决此问题的帮助/想法。
Any help/ideas to solve this issue are welcome.
推荐答案
默认情况下,Oracle驱动程序不会在 getColumns()
中返回有关同义词的信息。这在Oracle 11g JDBC开发人员指南中的 Performance Extensions中有记录。 :
By default the Oracle drivers does not return information on synonyms in getColumns()
. This is documented in the Oracle 11g JDBC Developer's Guide under Performance Extensions:
getColumns的注意事项
Considerations for getColumns
默认情况下, getColumns
如果指定了同义词,则方法不会检索有关列的信息。要在指定同义词时启用信息检索,您必须在连接上调用 setIncludeSynonyms
方法,如下所示:
By default, the getColumns
method does not retrieve information about the columns if a synonym is specified. To enable the retrieval of information if a synonym is specified, you must call the setIncludeSynonyms
method on the connection as follows:
( (oracle.jdbc.driver.OracleConnection)conn ).setIncludeSynonyms(true)
这将导致连接上的所有后续 getColumns
方法调用包含同义词。这类似于 setRemarksReporting
。或者,您可以设置 includeSynonyms
连接属性。这类似于 remarksReporting
连接属性。
This will cause all subsequent getColumns
method calls on the connection to include synonyms. This is similar to setRemarksReporting
. Alternatively, you can set the includeSynonyms
connection property. This is similar to the remarksReporting
connection property.
但是,请记住,如果 includeSynonyms
为true,如果存在同义词,则 table_name
列中返回的对象的名称将是同义词名称。即使您将表名传递给 getColumns
,也是如此。
However, bear in mind that if includeSynonyms
is true, then the name of the object returned in the table_name
column will be the synonym name, if a synonym exists. This is true even if you pass the table name to getColumns
.
注意要记住这最后一项非常重要!
Note that this last item is really important to keep in mind!
这篇关于DatabaseMetaData.getColumns返回同义词的空ResultSet的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!