清单 1. 检索自动产生的关键字
statement stmt = conn.createstatement();
// obtain the generated key that results from the query.
stmt.executeupdate("insert into authors " +
'(first_name, last_name) " +
"values ('george', 'orwell')",
statement.return_generated_keys);
resultset rs = stmt.getgeneratedkeys();
if ( rs.next() ) {
// retrieve the auto generated key(s).
int key = rs.getint();
}
jta/jts
1.jta/jts基本知识
服务器实现jts是否对应用程序开发人员来说不是很重要的。
对你来说,应该把jta看作是可用的api。
jta是用来开发distributed tansaction的 api.
而jts定义了支持jta中实现transaction manager 的规范。
javatransaction service (jts) specifies the implementation of a transaction manager which supports the java transaction api (jta) 1.0 specification at the high-level and implements the java mapping of the omg object transaction service (ots) 1.1 specification at the low-level. jts uses the standard corba orb/ts interfaces and internet inter-orb protocol (iiop) for transaction context propagation between jts transaction managers.
a jts transaction manager provides transaction services to the parties involved in distributed transactions: the application server, the resource manager, the standalone transactional application, and the communication resource manager (crm).
2.jta
1.1 事务处理的概念
jta实际上是由两部分组成的:一个高级的事务性客户接口和一个低级的 x/open xa接口。
我们关心的是高级客户接口,因为bean可以访问它,而且是推荐的客户应用程序的事务性接口。
低级的xa接口是由ejb服务器和容器使用来自动协调事务和资源(如数据库)的
1.1.1事务划分
a.程序划分
使用usertransaction启动jta事务
the usertransaction interface defines the methods that allow an application to explicitly manage transaction boundaries.(from j2ee api document) |
|