Programmatic transaction (Web hosting billing) demarcation In a nonmanaged environment, the
Programmatic transaction demarcation In a nonmanaged environment, the JDBC API is used to mark transaction boundaries. You begin a transaction by calling setAutoCommit(false) on a JDBC Connection and end it by calling commit(). You may, at any time, force an immediate rollback by calling rollback(). In a system that manipulates data in several databases, a particular unit of work involves access to more than one resource. In this case, you can t achieve atomicity with JDBC alone. You need a transaction manager that can handle several resources in one system transaction. Such transaction-processing systems expose the Java Transaction API (JTA) for interaction with the developer. The main API in JTA is the UserTransaction interface with methods to begin() and commit() a system transaction. Furthermore, programmatic transaction management in a Hibernate application is exposed to the application developer via the Hibernate Transaction interface. You aren t forced to use this API Hibernate also lets you begin and end JDBC transactions directly, but this usage is discouraged because it binds your code to direct JDBC. In a Java EE environment (or if you installed it along with your Java SE application), a JTA-compatible transaction manager is available, so you should call the JTA UserTransaction interface to begin and end a transaction programmatically. However, the Hibernate Transaction interface, as you may have guessed, also works on top of JTA. We ll show you all these options and discuss portability concerns in more detail. Programmatic transaction demarcation with Java Persistence also has to work inside and outside of a Java EE application server. Outside of an application server, with plain Java SE, you re dealing with resource-local transactions; this is what the EntityTransaction interface is good for you ve seen it in previous chapters. Inside an application server, you call the JTA UserTransaction interface to begin and end a transaction. Let s summarize these interfaces and when they re used: java.sql.Connection Plain JDBC transaction demarcation with set- AutoCommit(false), commit(), and rollback(). It can but shouldn t be used in a Hibernate application, because it binds your application to a plain JDBC environment.
Searching for affordable and proven webhost to host and run your servlet applications? Go to Linux Web Hosting services and you will find it.