比ORA-24777: 不允許使用不可移植的資料庫鏈路更讓人鬱悶的事情,ora-24777鏈路

來源:互聯網
上載者:User

比ORA-24777: 不允許使用不可移植的資料庫鏈路更讓人鬱悶的事情,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


相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.