Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> DatabaseMetaData.getColumns() returns 0 fileds when create a synonym on?
DatabaseMetaData.getColumns() returns 0 fileds when create a synonym
on?
Hi, There.
I met this problem:
1, create a user named tony (Roles: CONNECT,RESOURCE). Grant the SELECT
permis
sion on SCOTT.EMP to tony.
2, tony logon by sqlplus, "create synonym SYNO1 for SCOTT.EMP"
Then I tested the DatabaseMetaData.getColumns() using flowing code:
import java.sql.*;
import oracle.jdbc.driver.OracleDriver;
public class TestConnection {
public static void main(String[] args)
try {
String userName = "tony";
String userPassword = "tony";
String url = "jdbc:oracle:thin:@shg-d-01-tf:1521:tfang";
java.util.Properties info = new java.util.Properties(); info.put("user", userName); info.put("password", userPassword); info.put("includeSynonyms", "true"); // I need set it to true to uesthe synon
ym(SYNO1 ).
info.put("remarksReporting", "true");
DriverManager.registerDriver(new OracleDriver());
Connection conn =DriverManager.getConnection(url, info);
DatabaseMetaData md = conn.getMetaData();
String tableName = "EMP";
String schemaName = "SCOTT";
ResultSet rs = md.getColumns(null,schemaName,tableName,null);
int count = 0;
while (rs.next()){
count++;
System.out.println("count of " + tableName + "'s fields:" + count);
rs.close();
conn.close();
} catch (Exception e) {
e.printStackTrace();
The result:
count of EMP's fields:0
also I using scott login, it return 0 also.
When you set "includeSynonyms" to false,then the result is: count of EMP's fields:1
Enviroment: Oracle 9.2.0.1 / Windows server 2003 And using Oracle client 9.2 connect to Oracle server 8.1.7 also has this probl
em.
Any advice is helpful.
Thanks Received on Wed Mar 29 2006 - 03:43:46 CST
![]() |
![]() |