THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
...
- Create an EAR application that contains an EJB application packaging all entity classes, ejb classes and META-INF/persistence.xml
- Create META-INF/ejb-jar.xml. Since we have used annotations, we do not have to provide any declarations in it.
- Create a WEB application in the EAR and add the above servlet.
- Create a derby database by name
AccountDB
using admin console. - Create a table by name
ACCOUNT
as following.
The contents ofCode Block SQL SQL borderStyle solid title ACCOUNT table create table ACCOUNT(ACCOUNTNO integer, ACCOUNTTYPE varchar(50), NAME varchar(50), ADDRESS varchar(225), BRANCHCODE integer, INTERESTRATE decimal(15,2), MINBALANCE decimal(15,2), BALANCE decimal(15,2), CURRENTACCOUNTRULES varchar(225), SAVINGSACCOUNTRULES varchar(225))
ACCOUNT
table in theAccountDB
database are as follows
- Run the servlet with the following input
http://localhost:8080/<web-context>/Test?accNo=1&name=Joe
andhttp://localhost:8080/<web-context>/Test?accNo=3&name=John
.
- The following data will be inserted into
ACCOUNT
table.No Format borderStyle solid title ACCOUNT table ACCOUNTNO ACCOUNTTYPE NAME ADDRESS BRANCHCODE INTERESTRATE MINBALANCE BALANCE CURRENTACCOUNTRULES SAVINGSACCOUNTRULES 1 CURRENTACCOUNT Joe Joe's address 10 20.00 200.00 5000.00 Current Account!! 2 SAVINGSACCOUNT Joe Joe's address 12 234.00 4534.00 13323.00 Savings Account!! 3 CURRENTACCOUNT John John's address 10 20.00 200.00 5000.00 Current Account!! 4 SAVINGSACCOUNT John John's address 12 234.00 4534.00 13323.00 Savings Account!!
Note that JPA has inserted the value CURRENTACCOUNT
in the column ACCOUNTTYPE
for CurrentAccount entities and inserted the value {SAVINGSACCOUNT}} for SavingsAccount entites.