...
11. As outlined above, right click on the META_INF
directory of ContainerManagedJPA-EJB
project and
create persistence.xml
. Copy the following contents into persistence.xml
.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<?xml version="1.0" encoding="UTF-8"?> <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"> <persistence-unit name="AccountUnit" transaction-type="JTA"> <description>ContainerManagedJPA</description> <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider> <jta-data-source>AccountDS</jta-data-source> <class>sample.jpa.Account</class> </persistence-unit> </persistence> |
12. Since we are going to use EJB annotations, the META-INF/ejb-jar.xml
will not have any declarations. The contents of the META-INF/openejb-jar.xml
file should be as below. Otherwise, modify it accordingly.
Code Block | |||||
---|---|---|---|---|---|
| |||||
<?xml version="1.0" encoding="UTF-8"?> <openejb-jar xmlns="http://openejb.apache.org/xml/ns/openejb-jar-2.2" xmlns:naming="http://geronimo.apache.org/xml/ns/naming-1.2" xmlns:sec="http://geronimo.apache.org/xml/ns/security-2.0" xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.2"> <sys:environment> <sys:moduleId> <sys:groupId>ContainerManagedJPA</sys:groupId> <sys:artifactId>EJB</sys:artifactId> <sys:version>1.0</sys:version> <sys:type>car</sys:type> </sys:moduleId> <dependencies> <dependency> <groupId>console.dbpool</groupId> <artifactId>AccountDS</artifactId> </dependency> </dependencies> </sys:environment> <enterprise-beans/> </openejb-jar> |
...
5. Right click on the WebContent folder of the web project and navigate to New => HTML to create the index.html file as given in the screen shot. Click on the Next button and on the next screen click on the Finish button. The content of the index.html is provided below the screen shot.
Code Block | ActionScript | ActionScript|||
---|---|---|---|---|
| ||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Input Account Numbers and Amount</title> </head> <body> <form name="input" action="/ContainerManagedJPA-WEB/Test"method="get"> <table border="0"> <tr> <td align="right"><font color="black" size="5"> Debit Account Number</font></td> <td align="left"><input type="text" name="account1"></td> </tr> <tr> <td align="right"><font color="black" size="5"> Credit Account Number</font></td> <td align="left"><input type="text" name="account2"></td> </tr> <tr> <td align="right"><font color="black" size="5"> Amount to be Transfered </font></td> <td align="left"><input type="text" name="amount"></td> </tr> <tr> <td align="right"><input type="submit" value="Submit"></td> <td></td> </tr> </table> </form> </body> </html> |
...
4. The above step will create AccountDB
database. On the same screen, enter the below SQL command on the SQL Command/s textarea and select AccountDB in the Use DB combo box and click on the Run SQL button. This will create ACCOUNTCME table in the AccountDB database.
Code Block | SQL | SQL|
---|---|---|
| ||
create table ACCOUNTCME (ACCOUNTNUMBER integer, OWNERNAME varchar(100), BALANCE decimal(15,2)); |
...
5. Also insert two rows using the below SQL command.
Code Block | SQL | SQL|
---|---|---|
| ||
insert into ACCOUNTCME values (1, 'Phani',2000); insert into ACCOUNTCME values (2, 'Nag',2000); |
...