比ORA-24777: 不允许使用不可移植的数据库链路更让人郁闷的事情

本文介绍了解决在Oracle XA应用程序中使用数据库链接时遇到ORA-24777错误的方法。该错误通常发生在尝试通过专用服务器连接使用数据库链接时。提供了两种解决方案:一是配置数据库以允许使用共享服务器;二是定义被使用的数据库链接为共享数据库链接。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

   现场有一个同步功能报错,内容如下:
   java.sql.BatchUpdateException: ORA-24777: 不允许使用不可移植的数据库链路
   at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:10317)
   at oracle.jdbc.driver.OracleStatementWrapper.executeBatch(OracleStatementWrapper.java:216)
   at weblogic.jdbc.wrapper.PreparedStatement.executeBatch(PreparedStatement.java:210)

   1.了解了一下功能,大致如下:
      有A、B两个数据库,在A数据库上建了一个dblink,在XA的JDBC驱动下,通过dblink就会出现这种错误。

   2.此错误有些生僻,直接查metalink见附录。两种解决方案供选择:
    a. Configure the database to allow the use of shared servers

         ALTER SYSTEM SET DISPATCHERS="(PROTOCOL=TCP)" scope=both;

         ALTER SYSTEM SET SHARED_SERVERS = 10 scope=both;

    b. Define the database link being utilised as a shared database link,一定不要加public
     CREATE SHARED DATABASE LINK dblink_name
    [CONNECT TO username IDENTIFIED BY password]|[CONNECT TO CURRENT_USER]
    AUTHENTICATED BY schema_name IDENTIFIED BY password
     [USING 'service_name'];

   3.现场调整
      先用a方案在B数据库上调整了,用b方案在A数据库上做了调整,测试不行。再用a方案在A数据库上调整了,测试还是不行。

   4.到现场发现问题
      发现同义词不对,就是没有用到这个shared的dblink,艹,这太让人郁闷了,调了半天,没有用到。
  
   我认为的结论是:只要把A库中的dblink改为shared的方式就可以了。
     

Using Database Links in Oracle XA Applications

Oracle XA applications can access other Oracle Database instances through database links with these restrictions:

  • They must use the shared server configuration.

    The transaction processing monitors (TPMs) use shared servers to open the connection to an Oracle Database A. Then the operating system network connection required for the database link is opened by the dispatcher instead of a dedicated server process. This allows different services or threads to operate on the transaction.

    If this restriction is not satisfied, then when you use database links within an XA transaction, it creates an operating system network connection between the dedicated server process and the other Oracle Database B. Because this network connection cannot be moved from one dedicated server process to another, you cannot detach from this dedicated server process of database A. Then when you access the database B through a database link, you receive an ORA-24777 error.

  • The other database being accessed must be another Oracle Database.

If these restrictions are satisfied, Oracle Database allows such links and propagates the transaction protocol (prepare, rollback, and commit) to the other Oracle Database instances.

If using the shared server configuration is not possible, then access the remote database through the Pro*C/C++ application by using EXECSQL AT syntax.

The init.ora parameter OPEN_LINKS_PER_INSTANCE specifies the number of open database link connections that can be migrated. Thesedblink connections are used by XA transactions so that the connections are cached after a transaction is committed. Another transaction can use the database link connection if the user who created the connection also created the transaction. This parameter is different from the init.ora parameter OPEN_LINKS, which specifies the maximum number of concurrent open connections (including database links) to remote databases in one session. The OPEN_LINKS parameter does not apply to XA applications.


转到底部转到底部

In this Document

Symptoms
 Cause
 Solution

This document is being delivered to you via Oracle Support's Rapid Visibility (RaV) process and therefore has not been subject to an independent technical review.

APPLIES TO:

Oracle Server - Enterprise Edition - Version 10.2.0.5 to 11.2.0.3 [Release 10.2 to 11.2]
Information in this document applies to any platform.

SYMPTOMS

ORA-24777 reported by a JDBC/XA application when utilising a database link between two Oracle databases.

CAUSE

An ORA-24777 is a warning that you are trying to utilise a database link within an XA coordinated transaction and the connection to the source database which is trying to use the database link has been made through a dedicated server connection.

This is not allowed and this is documented in following entry

As per http://docs.oracle.com/cd/E11882_01/appdev.112/e25518/adfns_xa.htm#ADFNS809

in the following section 'Using Database Links in Oracle XA Applications'
.
 

SOLUTION

Two options

1. Configure the database to allow the use of shared servers and then let the application use these as per the following documentation

http://docs.oracle.com/cd/E11882_01/server.112/e25494/manproc003.htm#ADMIN00502

or establish whether the Java application needs to start an XA transaction.

OR

2. Define the database link being utilised as a shared database link, i.e,

CREATE SHARED DATABASE LINK ..

as per

http://docs.oracle.com/cd/E11882_01/server.112/e26088/statements_5005.htm#SQLRF01205


<think>好的,我现在需要帮助用户解决Oracle数据库中的ORA-04053、ORA-00604和ORA-16000错误。首先,我要逐一分析这些错误代码的含义和可能的原因,然后结合提供的引用内容,给出解决方案。 首先,ORA-04053错误。根据我的知识,这个错误通常与无效的对象或权限有关,比如在编译存储过程或触发器时,依赖的对象存在或没有权限访问。这时候需要检查相关对象的状态,比如是否被删除或失效,或者用户是否有足够的权限。 接下来是ORA-00604,这是一个比较常见的错误,可能由多种原因引起。根据用户提供的引用,特别是引用[2]和引用[5],ORA-00604可能与表空间足有关,尤其是SYSTEM表空间无法扩展,导致审计表SYS.AUD$无法写入。此外,引用[3]提到在备用数据库上增加tempfile时也可能出现这个错误,这可能与只读模式或权限有关。ORA-16000错误,如引用[4]所述,通常是因为数据库处于只读模式,无法进行写操作。 现在需要将这三个错误联系起来,找出它们的共同点或可能的触发场景。例如,当数据库处于只读模式(ORA-16000)时,尝试修改表空间或写入数据可能会触发ORA-00604,而如果在这个过程中有对象依赖问题,可能同时出现ORA-04053。过,ORA-04053也可能独立出现,比如在编译无效对象时。 接下来,我需要根据引用内容整理解决方案: 1. 对于ORA-04053:检查并重新编译无效对象,确保所有依赖对象存在且有效。可能需要使用UTL_RECOMP包或ALTER COMPILE语句。 2. 对于ORA-00604: - 检查表空间使用情况,特别是SYSTEM和临时表空间。引用[2]和[5]提到查询dba_free_space和dba_data_files来查看空间利用率,扩展表空间或清理AUD$表。 - 如果是备用数据库的问题(引用[3]),可能需要临时启用读写模式来增加tempfile,或调整主库配置。 - 检查审计设置,清理或转移审计数据,如引用[2]提到的启用审计跟踪或调整审计表存储位置。 3. 对于ORA-16000:确保数据库处于可写状态。如果是物理备用数据库,可能需要临时激活为可写或检查日志传输状态。 此外,综合错误处理步骤可能包括检查日志详细信息,确认具体报错上下文,以及必要时联系Oracle支持。 需要将这些步骤分点整理,确保结构清晰,并引用对应的引用来源。例如,处理表空间足时引用[2]和[5],处理备用数据库问题时引用[3],处理只读模式引用[4]。 最后,生成相关问题,帮助用户进一步排查可能的相关问题,比如如何监控表空间、如何管理审计表、备用库维护注意事项等。</think>### 分步解决方案:ORA-04053、ORA-00604、ORA-16000 错误处理 #### 1. **ORA-04053: 验证对象有效性** - **问题原因**:对象(如表、视图、存储过程)失效、权限足或依赖对象被删除。 - **解决步骤**: 1. 查询失效对象: ```sql SELECT owner, object_name, object_type FROM dba_objects WHERE status = 'INVALID'; ``` 2. 手动编译无效对象: ```sql ALTER PACKAGE <schema>.<package_name> COMPILE; ALTER VIEW <schema>.<view_name> COMPILE; ``` 3. 使用`UTL_RECOMP`工具批量编译: ```sql EXEC UTL_RECOMP.RECOMP_SERIAL(); ``` #### 2. **ORA-00604: 处理表空间与审计表问题** - **场景1:表空间足(ORA-01653)** [^2][^5] - **检查空间使用率**: ```sql SELECT tablespace_name, file_name, bytes/(1024*1024) "总大小(MB)", (bytes - sum(nvl(bytes,0)))/(1024*1024) "已用(MB)", round((bytes - sum(nvl(bytes,0)))/bytes*100,2) "利用率(%)" FROM dba_data_files JOIN dba_free_space USING(file_id) GROUP BY tablespace_name, file_name, bytes; ``` - **扩展表空间**: ```sql ALTER DATABASE DATAFILE '<数据文件路径>' RESIZE 2G; --扩展数据文件 ALTER TABLESPACE SYSTEM ADD DATAFILE '<新路径>' SIZE 1G; --新增数据文件 ``` - **清理审计表`AUD$`**: ```sql TRUNCATE TABLE SYS.AUD$; --需谨慎操作,建议备份 ALTER TABLE SYS.AUD$ MOVE TABLESPACE <新表空间>; --迁移至其他表空间 ``` - **场景2:备用库增加临时文件失败** [^3] - 若备用库处于只读模式,需在主库执行操作: ```sql ALTER TABLESPACE TEMP ADD TEMPFILE '<路径>' SIZE 500M; ``` - 或临时激活备用库为读写模式(需重建备用库): ```sql ALTER DATABASE ACTIVATE STANDBY DATABASE; ``` #### 3. **ORA-16000: 数据库只读模式冲突** [^4] - **确认数据库模式**: ```sql SELECT open_mode FROM v$database; --应为READ WRITE ``` - **物理备用库处理**: - 检查日志传输状态,确保主库正常同步。 - 若需临时写入,创建临时快照(需Oracle Active Data Guard选件): ```sql ALTER DATABASE OPEN READ WRITE; --仅支持特定版本 ``` #### 4. **综合排查与审计配置** - **启用审计跟踪** [^1]: ```sql AUDIT SELECT TABLE, INSERT TABLE BY ACCESS; --按需配置审计策略 ``` - **检查错误日志**: ```sql SELECT * FROM v$diag_info WHERE name = 'Default Trace File'; --定位详细日志 ``` --- ### 相关问题 1. 如何监控Oracle表空间使用情况并设置自动扩展? 2. 物理备用数据库在只读模式下有哪些操作限制? 3. 审计表`SYS.AUD$`的维护和清理有哪些最佳实践? 4. 如何避免因对象失效导致的ORA-04053错误? 通过上述步骤,可系统性解决ORA-04053、ORA-00604和ORA-16000错误,并根据实际场景选择对应策略[^3][^5]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值