JDBC 连接字符串和 Oracle 同义词
我们有一个 Java 程序通过 JDBC 瘦客户端连接到 Oracle 10g 数据库。
一切都工作正常,但现在 DBA 希望我们使用不同的用户名/密码进行连接,该用户名/密码应该可以使用公共同义词访问相同的表。 不幸的是,Java 程序不再看到这些表(当我尝试执行“select * from tablename”时,请参阅下面的错误)。
我尝试使用相同的用户名/密码与 Oracle SQL Developer 进行连接,在这种情况下,我可以毫无问题地运行“select * from tablename”。
我需要在连接字符串中放入特定参数吗?
非常感谢!
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
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 tablename").
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须将架构名称与表名称一起附加,并使用大写字母(我不记得是否区分大小写或仅大写)。
例子:
如果 SCH1 中有一个 Employee 表,并且在 SCH2 中创建同义词作为 Emp for SCH2.Employee,则以下语句有效,
其中,
emp:同义词名称
SCH2:创建此同义词的架构名称,而不是实际表的架构名称。
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,
Where,
emp: Synonym Name
SCH2: Schema Name where this synonym is created, not the Schema Name of the actual table.