gpt4 book ai didi

java - DatabaseMetaData.getColumns 为同义词返回一个空的结果集

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:47:30 24 4
gpt4 key购买 nike

元数据上的方法 getColumns() 为同义词返回一个空的结果集(对于表和 View ,它正确地返回列列表)。

这发生在 Oracle 11g Express 上并使用最新的 Oracle JDBC 驱动程序 (11.2.3)。

其他 SQL 服务器是否也会发生这种情况?

欢迎提供解决此问题的任何帮助/想法。

最佳答案

默认情况下,Oracle 驱动程序不会在 getColumns() 中返回有关同义词的信息。这记录在 Oracle 11g JDBC 开发人员指南中 Performance Extensions 下:

Considerations for getColumns

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)

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.

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.

请注意,记住最后一项非常重要!

关于java - DatabaseMetaData.getColumns 为同义词返回一个空的结果集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18545646/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com