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:
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
.
Note that this last item is really important to keep in mind!