JPA is a simple programming model for Entity Persistence.
BTT leverages the capability of JPA to facilitate access of database.
For more information about JPA, please refer to http://publib.boulder.ibm.com/infocenter/radhelp/v8/index.jsp?topic=/com.ibm.jpa.doc/topics/c_jpa.html.
In this case, we are going to use a Derby Embedded database, which
is lightweight and much easy to demonstrate this sample, to store
business data.
To create and populate the Derby database, please open the
Data Source Explorer view. Right click on Database Connections and
select “New …” to open new data source creation wizard.
Then select “Derby” as database manager on the left, set JDBC
driver to Derby Embedded JDBC Driver, choose a location for your database,
make sure to check on “Create database (if required)” option. You
can click the “Test Connection” button to test the settings, if the
test return success, please copy and remember the JDBC URL, then click
“Finish” button to complete.
- Now we are going to create required tables and initial data records
in the Derby database by executing a SQL file.
- Please open project “BusinessTemplatesUtils”, find Script.sql,
right click on it and select “Execute SQL Files”.
- In the popup dialog, select Derby as database server type, the
newly created data source name as connection profile name, and the
database you created just now.
- Then “OK” to start execution of the SQL file.You will see some results listed
one by one in the SQL Results view. There should have no errors during
the execution.
- Once the execution is finished, please right click the data source
and choose “Disconnect” to disconnect the database connection, because
that is an embedded database, the WebSphere Application Server would
not be able to connect to it while it is opened by Data Source Explorer.
- Now we have to check persistence.xml under BusinessTemplatesUtils
project. All database access information is configured here.
- Make sure the transaction-type is “RESOURCE_LOCAL”, and no data
source name in this line.
- Make sure the openjpa.ConnectionURL is the correct JDBC URL we
copied and remembered just now while we creating the data source.
