Thursday, April 9, 2009

Configuring Oracle XE connection pool in Glassfish and Using JPA

I followed these instructions for creating an Oracle JDBC datasource. I needed to download the Oracle JDBC driver (ojdbc14.jar) into my <Glassfish>/lib directory and restart the server. After that the “Ping” was successful.

In “step 2” I had to specify 4 properties: user, password, url, and xa-driver-does-not-support-non-tx-operations.

Next I needed to create a JDBC resource that my persistence.xml file would reference.

With those tasks complete, I modified an existing EJB 3 JPA project to utilize the new connection pool. All that was necessary was to change two lines in the persistence.xml file. First was to point to the new JNDI name:

<jta-data-source>jdbc/AMRPool</jta-data-source>

And second was to change the “toplink.platform.class.name” (now deprecated) to:

<property name="toplink.target-database" value="Oracle"/>

After redeploying the JAR the CUSTOMER table was added to my schema. I re-ran the test client and was delighted to find a record in the table. Bravo to the Java community!

1 comment:

danceofdeath81 said...

much thanx, very simple and bigger help