- 浏览: 96971 次
- 性别:
- 来自: 上海
最新评论
-
shmily2038:
有相应的例子? 给的全部是英文,还不如自己看官网e文。 上代 ...
ActiveMQ集群随记 -
lutian1984:
你好,你验证过你转发的这个东西吗?为什么在我这里还是报错呢?
jquery.form.js ajax上传文件问题 -
chenhongwei0924:
精辟.
如何防止SQL注入 -
fairyhawk:
简单的几句,经验的总结。
如何防止SQL注入 -
joliny:
谢谢了,这个问题也困扰了我很久、!
Apache整合Tomcat后get方式提交中文乱码问题解决
FAQs: JTA
Can I use a non-XA driver in distributed transactions?
Can I use more than one non-XA connection pool in distributed transactions?
How do XA and non-XA drivers differ in distributed transactions?
What XA drivers can I use in addition to the WebLogic jDriver for Oracle/XA?
Can I use the Oracle thin driver as an XA driver in distributed transactions?
Why do I get SQLException "Result set already closed" message?
Do I need a 2PC licence when I use JMS with one JDBC non-XA driver?
Why am I getting an exception when I use JMS with a non-XA driver?
Why do I get an exception when I use EJB CMP 1.1?
Can I obtain a JDBC connection before I start a distributed transaction?
Can I close a JDBC connection after the distributed transaction is committed or rolled back?
Can I use a non-XA driver in distributed transactions?
When the non-XA connection pool is the only resource participating in a transaction distributed across multiple servers, you just need to configure a TxDataSource for the non-XA driver. (This configuration is the same as the JTS driver usage in WLS 5.1.)
However, when more than one resource participates in the distributed transaction, you must also set the TxDataSource property EnableTwoPhaseCommit=true. For more information, see Managing JDBC Connectivity in the Administration Guide. In both cases, always obtain a connection via the DataSource interface, not through the deprecated DriverManager interface. If you obtain a connection via DriverManager, the interface cannot pick up the EnableTwoPhaseCommit setting of the TxDataSource; this may result in unexpected behavior in distributed transactions. Also, when you use the DataSource interface, you do not need to distinguish either the URL or the specific WebLogic multitier driver (JTS, RMI, or pool.) The URL and specific driver are obtained through the config.xml file and JNDI lookup.
Can I use more than one non-XA connection pool in distributed transactions?
No. Even if you set EnableTwoPhaseCommit=true for both TxDataSources of the connection pools, attempting to use two non-XA connection pools in the same distributed transaction will result in
"java.sql.SQLException: Connection has already been created in this tx context for pool named <first name=""></first>. Illegal attempt to create connection from another pool: <second name=""></second>"
when you attempt to get the connection from the second non-XA connection pool.
How do XA and non-XA drivers differ in distributed transactions?
The differences between XA and non-XA JDBC drivers are:
Atomicity Guarantee. An XA driver implements the XAResource interface and can participate fully in the 2PC protocol driven by the WLS Transaction Manager. This guarantees atomicity of updates across multiple participating resources.
However, a non-XA driver does not implement the XAResource interface and cannot fully participate in the 2PC protocol. When using a non-XA driver in a distributed transaction, WLS implements the XAResource wrapper on behalf of the non-XA driver. If the data source property enableTwoPhaseCommit is set to true, then the WLS XAResource wrapper returms XA_OK when the Transaction Manager calls prepare on it. When the Transaction Manager calls commit or rollback on it during the second phase, the WLS XAResource wrapper delegates the commit/rollback call to the non-XA JDBC connection. Any failure during commit/rollback results in heuristic exceptions. Application data may be left in an inconsistent state as a result of heuristic failure.
Redirecting Connections. As in WLS 5.1, a non-XA driver can be configured to perform updates in the same distributed transaction from more than one process, as explained in Can I use a non-XA driver in distributed transactions?. WLS internally redirects the JDBC calls made from different processes to the same physical JDBC connection in one process. However, when you use a XA driver, no such redirection will be done. Each process will use its own local XA database connection, and the database ensures that all the distributed updates made in the same distributed transaction from different processes will be committed atomically.
Connection Management. Whether you are using the non-XA driver or XA driver in distributed transactions, WLS implements JDBC wrappers that intercept all the JDBC calls and obtains a physical JDBC connection from the connection pool on demand.
When you use a non-XA driver in distributed transactions, in order to ensure that updates made from different processes are committed atomically, WLS associates the same physical JDBC connection with the distributed transaction until it is committed or rolled back. As a result, the number of active distributed transactions using the non-XA connection pool is limited by the maximum capacity of the JDBC connection pool.
When you use an XA driver, the connection management is more scalable. WLS does not hold on to the same physical XA connection until the transaction is committed or rolled back. In fact, in most cases, the XA connection as only held for the duration of a method invocation. WLS JDBC wrappers intercept all JDBC calls and enlist the XAResource associated with the XA connection on demand. When the method invocation returns to the caller, or when it makes another call to another server, WLS delists the XAResource associated with the XA connection.
WLS also returns the XA connection to the connection pool on delistment if there are no open result sets. Also, during commit processing, any XAResource object can be used to commit any number of distributed transactions in parallel. As a result, neither the number of active distributed transactions using the XA connection pool nor the number of concurrent commit/rollbacks is limited by the maximum capacity of the connection pool. Only the number of concurrent database access connections is limited by the maximum capacity of the connection pool.
What XA drivers can I use in addition to the WebLogic jDriver for Oracle/XA?
Theoretically, you can use any third party XA driver that is compliant with the JDBC 2.0 standard extension specification with WLS. However, an individual vendor's XA driver may have bugs that prevent it from working properly.
Refer to JDBC Configuration guidelines for details about how to configure them at ../adminguide/managetx.html.
Can I use the Oracle thin driver as an XA driver in distributed transactions?
Oracle 8.1.6 thin driver has a bug that does not accept any foreign Xid, and so does not work at all with any other vendor's transaction manager, including WLS.
Oracle 8.1.7 thin driver has threading problems and we do not recommend using it at this point. A workaround is not yet available in SP1. It will be available in the Silversword release. For this workaround, we use a dedicated XA connection for the duration of prepare, commit, and rollback operation. This is different from the default XA connection management model (see FAQ 3 for description) in that any XAResource object is used to commit any number of transactions in parallel. This limits the number of concurrent commits to the max capacity of the XA connection pool. Note that this workaround is an Oracle specific workaround and will not affect the usage of other XA drivers.
Meanwhile, if you still want to try it out in SP1 without the workaround, you can configure the XA connection pool. For more information, see Managing JDBC Connectivity in the Administration Guide.
Why do I get SQLException "Result set already closed" message?
Problem: I am using Weblogic jDriver for Oracle/XA (transaction mode) from the client side. Updating in a distributed transaction works fine. However, when I try to perform a query, I get SQLException Result set already closed. How do I work around this?
Weblogic jDriver for Oracle has a limitation that closes all open result sets when the method returns to the caller. For more information, see Limitations of the Weblogic jDriver for Oracle XA in Using WebLogic jDriver for Oracle/XA in Distributed Transations.
Using the driver from the server side, for example, in a bean, does not have this limitation. Using the driver from the server side is also recommended from application architecture and performance perspective. Using the driver from the client side incurs round-trip cost for every JDBC call being made.
This limitation exists because Weblogic jDriver for Oracle XA is implemented using Oracle's OCI API and C XA switch, and there is an Oracle problem when using OCI with XA in multi-threaded mode. Closing an OCI cursor in a thread that is different than the thread in which it is opened may result in server crash or unexpected behavior. As a result, the Weblogic driver implicitly closes all open result sets upon returning a call to the caller.
Do I need a 2PC licence when I use JMS with one JDBC non-XA driver?
Yes, you do. JMS is also a XAResource that participates in the distributed transaction. Therefore, there are two resources participating in the distributed transaction, and a 2PC license is needed.
Why am I getting an exception when I use JMS with a non-XA driver?
Problem: I am using JMS with one JDBC non-XA driver. Transaction fails to commit with the following exception: javax.transaction.xa.XAException: JDBC driver does not support XA, hence cannot be a participant in two-phase commit.
As mentioned in the previous question Do I need a 2PC licence when I use JMS with one JDBC non-XA driver?, JMS is also a XAResource that participates in the distributed transaction. When more than one resource is participating in the distributed transaction, you need to set the data source property EnableTwoPhaseCommit=true as explained in " Can I use a non-XA driver in distributed transactions?"
Why do I get an exception when I use EJB CMP 1.1?
Problem: I am using distributed transactions with EJB CMP 1.1 and a non-XA connection pool. I configured the JDBC connection pool and the TxDataSource according to instructions in Can I use a non-XA driver in distributed transactions?. However, commit still gives javax.transaction.xa.XAException: JDBC driver does not support XA, hence cannot be a participant in two-phase commit. Why?
The old style CMP 1.1 DTD does not allow you to specify the data source name. When only the connection pool name is specified, the EnableTwoPhaseCommit setting of the TxDataSource is ignored. You should use the new style CMP 1.1 DTD and specify the data source name instead of the pool name.
To ensure that the descriptor is using the latest DTD file, verify that the DOCTYPE header for the WebLogic CMP 1.1 descriptor file is as follows:
To see the DTD file, go to http://www.bea.com/servers/wls600/dtd/weblogic-rdbms11-persistence-600.dtd.
Can I obtain a JDBC connection before I start a distributed transaction?
This depends on whether you are using a non-XA or XA driver.
When you use a non-XA driver in a distributed transaction, always obtain a JDBC connection after the distributed transaction is begun.
If you are using an XA driver, you can obtain the connection before the distributed transaction is begun.
Can I close a JDBC connection after the distributed transaction is committed or rolled back?
For both non-XA and XA driver, you can close the connection after the distributed transaction is completed.
http://edocs.bea.com/wls/docs60/faq/transactions.html
发表评论
-
佳文收藏 - How to redirect a web page, the smart way
2010-08-05 10:48 1671本文引自:http://www.stevenhargrove. ... -
关于sojo输出json中出现~unique-id~字样的问题
2010-07-20 10:27 3124问题:在项目中,问题的表现如下,使用SojoJsonStrin ... -
jquery.form.js ajax上传文件问题
2010-07-20 10:25 4860问题:使用jquery.form.js实现ajax上传文件功能 ... -
Ehcache集群随记
2009-11-10 09:28 1737Distributed Caching with ehcach ... -
ActiveMQ集群随记
2009-11-10 09:28 3967Problem: cluster on JMS queue o ... -
常用第3方类库
2009-11-02 10:47 816转自:http://www.iteye.com/n ... -
项目中一次正则表达式的实践
2009-10-23 17:13 976今天在项目中遇到这样一个需求: 要求把一段HTML代码中的注释 ... -
DateFormat
2009-08-20 17:01 828from http://shib.kuleuven.be/do ... -
A few frequently used SSL commands
2009-08-19 13:13 1154常用导入证书 %JAVA_HOME%\jre\lib\secu ... -
缓存比较笔录
2009-07-29 18:08 1033ehcache 比较常用的轻量级缓存框架,是hibernate ... -
CAS单点登录入门使用
2009-07-29 16:34 1023单点登录------CAS http://zhyerr.blo ... -
MySQL数据库引擎介绍
2009-07-29 16:28 1733如果你是个赛车手,并 ... -
在Sql Server中使用pst根据字符型类型查询的性能问题
2009-03-23 10:59 1004问题:在使用mssqlserver的jdbc时,当根据字符型列 ... -
Ibatis事务的一些小结
2009-03-11 10:33 3150问题发生:原先在使用Ibatis的时候进行insert, up ... -
Ajax应用的安全性小结
2009-02-12 09:47 865对Ajax应用的安全性进行一下小结: 1.基于各浏览器的ser ... -
如何防止SQL注入
2009-02-10 10:05 4124归纳一下,主要有以下几点: 1.永远不要信任用户的输入。对用户 ... -
How to make thread safe
2009-01-11 16:39 984How to make thread safe 1.Use i ... -
Java怎样中断一个运行中的线程
2009-01-09 10:15 1052程序是很简易的。然而,在编程人员面前,多线程呈现出了一组新的难 ... -
Apache整合Tomcat后get方式提交中文乱码问题解决
2009-01-08 11:34 2671我在Tomcat中的8080的connector里配置了URI ... -
Quartz 与 Spring 配置注意事项
2008-08-29 18:05 1475在Spring配置和Quartz集成内容时,有两点需要注意 1 ...
相关推荐
### JavaEE经典面试题集锦知识点详解 #### 一、基础问答 1. **可被继承的类**:`java.lang.Thread` 和 `java.lang.ClassLoader` 是可被继承的,因为它们没有被声明为`final`。而`java.lang.Number`、`java.lang....
- J2EE是Sun公司定义的一套标准,包含一组用于构建企业级应用的API和服务,如JDBC、JMS、JTA、JPA等。 9. **其他常见问题**: - J2EE提供了诸如负载均衡、事务管理、安全性、数据持久化等功能。 - Servlet和JSP...
10. **事务管理**:Spring的事务管理能力覆盖了从本地事务到全局事务(JTA),提供了统一的接口进行事务控制,简化了事务处理。 总的来说,Spring框架以其强大的功能和灵活性,成为了Java开发的首选框架之一。它...
### Java面试经典题目详解 #### 一、Java基础问答深入解析 1. **哪些类可以被继承?** 在给出的示例中,`java.lang.Thread`和`java.lang.ClassLoader`是可以被继承的,而`java.lang.Double`, `java.lang.Math`, `...
用 JTA 的分布式事务)。1、什么是 Spring 框架?Spring 框架是一个开源的 Java 应用开发框架,它旨在简化企业级应用的开发。Spring 提供了一个全面的编程和配置模型,用于创建现代、松耦合的Java应用程序。Spring ...
【J2EE面试题集锦】涵盖了从基础问答到高级技术点,以下是对这些知识点的详细解析: 1. **继承性**: - `java.lang.Thread`、`java.lang.Number` 和 `java.lang.ClassLoader` 可以被继承,因为它们不是final类。而...
### J2EE基础问答 #### 可继承的类 - `java.lang.Thread`:可被继承,用于创建自定义线程类。 - `java.lang.Number`:可被继承,是所有数值类的父类。 - `java.lang.ClassLoader`:可被继承,用于加载类和资源。 #...
#### 一、基础问答 1. **哪些类可以被继承?** - `java.lang.Thread`: 可以被继承 (T)。 - `java.lang.Number`: 不可被继承 (F),因为它是抽象类。 - `java.lang.Double`: 不可被继承 (F),因为它是`final`类。 ...
首先,我们从基础问答开始。 1. 类继承问题:在Java中,`java.lang.Thread`和`java.lang.ClassLoader`是可以被继承的,因为它们没有被声明为final。而`java.lang.Number`、`java.lang.Double`、`java.lang.Math`、`...
### 基础问答 #### 1. 可以被继承的类 - `java.lang.Thread`: 可以被继承。 - `java.lang.Number`: 可以被继承。 - `java.lang.Double`: 不可被继承。 - `java.lang.Math`: 不可被继承。 - `java.lang.Void`: 不可被...
#### 基础问答 **1. 下面哪些类可以被继承?** - `java.lang.Thread`: 可以被继承 (`T` 表示True)。 - `java.lang.Number`: 可以被继承 (`T` 表示True)。 - `java.lang.Double`: 不可被继承 (`F` 表示False),因为...
《J2EE面试指南:基础问答、程序运行与数据库操作》 J2EE(Java 2 Platform, Enterprise Edition)是Java平台的企业版,主要用于构建分布式、多层的企业级应用程序。在J2EE面试中,面试官通常会关注应聘者的基础...
- **JTA(Java Transaction API)**:分布式事务的处理。 - **JPA(Java Persistence API)/Hibernate**:对象关系映射(ORM)技术,了解JPQL(Java Persistence Query Language)。 3. **开源框架** - **Spring...
【压缩包子文件的文件名称列表】"网考截屏题"很可能包含的是各个题目或部分试题的屏幕截图,可能包括选择题、填空题、问答题等多种题型。通过这些截图,学习者可以复习J2EE和J2ME的关键概念,如J2EE的Servlet、JSP、...
复习内容详细列举了可能出现在考试中的题型,如判断题、选择题、填空题和问答题,以及各部分的考题比例。 【Java EE基础知识】 1. Java 5的新特性:自动装箱/拆箱、可变参数、枚举类型、泛型、for-each循环、静态...
5. **JTA/JTS**(Java Transaction API/Java Transaction Service):处理分布式事务,确保数据一致性。 6. **EJB(Enterprise JavaBeans)**: 提供了面向服务的组件模型,用于构建可复用的服务器端组件。 **J2EE...
描述中的"JAVA web 学习资源资料"表明这是一个关于学习Java Web开发的资源集合,可能包括教程、示例代码、文档、问答集等,这些资源对于初学者和进阶者都极具价值。 标签"WEB J2EE"进一步确认了我们关注的重点,即...
### 一、基础问答 #### 1. 下面哪些类可以被继承? - `java.lang.Thread`:可被继承(T) - `java.lang.Number`:可被继承(T) - `java.lang.Double`:不可被继承(F) - `java.lang.Math`:不可被继承(F) - `...