Part I Development Tasks and Tools
1. Setting Up a Development Environment
3. Using Ant with Enterprise Server
Part II Developing Applications and Application Components
7. Using the Java Persistence API
8. Developing Web Applications
9. Using Enterprise JavaBeans Technology
10. Using Container-Managed Persistence
13. Developing Lifecycle Listeners
Part III Using Services and APIs
14. Using the JDBC API for Database Access
15. Using the Transaction Service
Configuring the Transaction Service
The Transaction Manager, the Transaction Synchronization Registry, and UserTransaction
Recovery Workarounds and Limitations
Manual Transaction Recovery Limitation
16. Using the Java Naming and Directory Interface
For multi-core machines, logging transactions to a database may be more efficient.
To log transactions to a database, follow these steps:
Create a JDBC connection Pool, and set the non-transactional-connections attribute to true.
Create a JDBC resource that uses the connection pool and note the JNDI name of the JDBC resource.
Create a table named txn_log_table with the schema shown in Table 15-1.
Add the db-logging-resource property to the transaction service. For example:
asadmin set server-config.transaction-service.property.db-logging-resource="jdbc/TxnDS"
The property's value should be the JNDI name of the JDBC resource configured previously.
To disable file synchronization, use the following asadmin create-jvm-options command:
asadmin create-jvm-options -Dcom.sun.appserv.transaction.nofdsync
Restart the server.
For information about JDBC connection pools and resources, see Chapter 14, Using the JDBC API for Database Access. For more
information about the asadmin create-jvm-options command, see the
Sun GlassFish Enterprise Server v3 Reference Manual.
|
The size of the SERVERNAME column should be at least the length of the Enterprise Server host name plus 10 characters.
The size of the GTRID column should be at least 64 bytes.
To define the SQL used by the transaction manager when it is storing its transaction logs in the database, use the following flags:
-Dcom.sun.jts.dblogging.insertquery=sql statement -Dcom.sun.jts.dblogging.deletequery=sql statement
The default statements are as follows:
-Dcom.sun.jts.dblogging.insertquery=insert into txn_log_table values ( ?, ? , ? ) -Dcom.sun.jts.dblogging.deletequery=delete from txn_log_table where localtid = ? and servername = ?
To set one of these flags using the asadmin create-jvm-options command, you must quote the statement. For example:
create-jvm-options '-Dcom.sun.jts.dblogging.deletequery=delete from txn_log_table where gtrid = ?'
You can also set JVM options in the Administration Console. Select the Application Server component and the JVM Settings tab. These flags and their statements must also be quoted in the Administration Console. For example:
'-Dcom.sun.jts.dblogging.deletequery=delete from txn_log_table where gtrid = ?'