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

现场有一个同步功能报错,内容如下:

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

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.

ORA-24777 reported when using a database link from within an XA coordinated transaction
(文档 ID 1506756.1)
转到底部

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

时间: 2024-11-09 10:46:32

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

弄清 ORA-24777:不允许使用不可移植的数据库链路 产生的原因,以及解决方法

最近一个同事咨询,说有一个含有dblink的SQL,在plsql中这个SQL可以正常执行,而在JAVA后台调用执行这个SQL执行要报错:ORA-24777:不允许使用不可移植的数据库链路. 请同事跟踪程序进去后,发现是通过dblink查询某个远程库表,而且使用了XA分布式事务数据库连接.以前也知道XA有不少坑,都绕着走了.但这次既然遇到了,就准备解决了方便以后,有个统一的解决方案.去查了下metalink,恰好有一篇文章提到这个问题:ORA-24777 reported when using a

discuz论坛移植修改数据库配置

从其他地方拷贝的discuz源码,可能需要修改数据库配置 分别打开discuz目录下面以下三个文件 discuzRoot/uc_server/data/config.inc.phpdiscuzRoot/config/config_ucenter.phpdiscuzRoot/config/config_global.php 将前面几行的DBHOST,DBUSER,DBPASS 也就是数据库主机名,数据库用户名和数据库密码改成正确的即可. discuz论坛移植修改数据库配置

XA中使用dblink发现的一个oracle bug

最近监控系统日志时发现出现一个新的错误信息,很奇怪,之前没有过.如下: ORA-24777:不允许使用不可移植的数据库链路. 跟踪程序进去发现是通过dblink查询某个远程库表,而且由于使用了XA分布式事务数据库连接.大家也许都知道XA有不少限制条件,之前也遇到过,都绕着走了.但是最近没有调整过程序也没有改变过dblink的配置,怎么回事呢?只能网上搜索,结果有人遇到过,说是oracle dblink改成shared就行了.个人觉得这个说法靠谱.于是现在测试系统上试了一下,果然有效. 可以为什么

Hibernate 这么硬核,为什么用的人少?

关于SQL和ORM的争论,永远都不会终止,我也一直在思考这个问题.最近温习了一遍SSH框架,发了动弹,和广大猿友进行了深刻的探讨,被喷的五体投地,感慨万千,于是就有了今天这篇文章. 声明:本文只是小编的一点拙见,不喜勿喷. 一.hibernate优势 hibernate让你不用写sql了,这不单可以让你的应用更好移植其它数据库,更主要的是让程序员更专注业务逻辑.数据关系.对象关系等.hibernate对一对多,多对多关系实现是非常好的.很关键一点,它支持lazy,可以让你的数据只在需要的时候被加

Oracle 错误总结及问题解决 ORA

参考地址 ORA-00001: 违反唯一约束条件 (.)错误说明:当在唯一索引所对应的列上键入重复值时,会触发此异常.ORA-00017: 请求会话以设置跟踪事件ORA-00018: 超出最大会话数ORA-00019: 超出最大会话许可数ORA-00020: 超出最大进程数 ()ORA-00021: 会话附属于其它某些进程:无法转换会话ORA-00022: 无效的会话 ID:访问被拒绝ORA-00023: 会话引用进程私用内存:无法分离会话ORA-00024: 单一进程模式下不允许从多个进程注册

Oracle 错误代码详解及解决方式--ORA

ORA-00001: 违反唯一约束条件 (.)错误说明:当在唯一索引所对应的列上键入重复值时,会触发此异常.ORA-00017: 请求会话以设置跟踪事件ORA-00018: 超出最大会话数ORA-00019: 超出最大会话许可数ORA-00020: 超出最大进程数 ()ORA-00021: 会话附属于其它某些进程:无法转换会话ORA-00022: 无效的会话 ID:访问被拒绝ORA-00023: 会话引用进程私用内存:无法分离会话ORA-00024: 单一进程模式下不允许从多个进程注册ORA-0

ora错误解释

ORA-00001: 违反唯一约束条件 (.)错误说明:当在唯一索引所对应的列上键入重复值时,会触发此异常.ORA-00017: 请求会话以设置跟踪事件ORA-00018: 超出最大会话数ORA-00019: 超出最大会话许可数ORA-00020: 超出最大进程数 ()ORA-00021: 会话附属于其它某些进程:无法转换会话ORA-00022: 无效的会话 ID:访问被拒绝ORA-00023: 会话引用进程私用内存:无法分离会话ORA-00024: 单一进程模式下不允许从多个进程注册ORA-0

[STM32F429-DISCO-uCosiii]1.uCOSIII 移植

uCOSiii的结构比uCOSii看上去是清晰了不少,也比较有条理,所以呢,移植不是让人感觉很乱.在工程中添加如下目录和文件      与CPU相关的文件都集中在uC-CPU文件夹中.这部分有很多是底层的实现,比如调度算法,CPU现场保护,前导零,时间相关的函数,其中也有不少我们需要自己来添加相关代码.库文件提供了我们对字符串.数学运算.存储运算等的处理函数,ucOS-OS提供了操作系统的各功能模块代码.移植的详细步骤UCOSiii user manual.pdf比较详细 我参考其中文译书<嵌入

嵌入式linux开发uboot移植(七)——三星官方uboot的移植

嵌入式linux开发uboot移植(七)--三星官方uboot的移植 友善之臂Smart210开发板是基于三星SMDKV210评估板裁剪.调整而来的.因此三星官方发布的基于SMDKV210评估板的uboot是移植uboot到Smart210开发板的最合适uboot版本.本文将SMDKV210的uboot移植到Smart210开发板.Smart210开发板的配置如下: SoC:Samsung S5PV210 SDRAM:512MB DDR2 RAM FLASH存储:2G MLC NAND Flas