开发者

JDBC connect string and Oracle synonyms

we have a Java program connecting via JDBC thin client to an Oracle 10g database.

Everything was working fine, but now the DBA wants us to connect with a different username/password, which is supposed to have access to the same tables using public synonyms. Unfortunately the Java program no longer sees the tables (see error below when I try to do "select * from tabl开发者_开发问答ename").

I have tried to connect using the same username/password with Oracle SQL Developer and in this case I can run "select * from tablename" without problems.

Is there a specific Parameter I need to put in the connect string?

Many thanks!

Exception in thread "main" java.sql.SQLException: ORA-00942: table or view does not exist
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)
at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:207)
at oracle.jdbc.driver.T4CStatement.executeForDescribe(T4CStatement.java:790)
at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1037)
at oracle.jdbc.driver.T4CStatement.executeMaybeDescribe(T4CStatement.java:830)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1132)
at oracle.jdbc.driver.OracleStatement.executeInternal(OracleStatement.java:1687)
at oracle.jdbc.driver.OracleStatement.execute(OracleStatement.java:1653)

Edited by: user555817 on 08-Oct-2010 04:55


You have to append Schema Name along with the table name and make it in capital letters (I dont remember if that is case-sensitive or just caps).

Example: If there is an Employee Table in SCH1 and the synonym is created in SCH2 as Emp for SCH2.Employee, then the below statement is valid,

    SELECT * FROM SCH2.emp

Where, emp: Synonym Name SCH2: Schema Name where this synonym is created, not the Schema Name of the actual table.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜