DB Lab 2 - Select, insert, update and delete records with Java bean 
- In the last lab, we looked at retrieving records. In this lab we will be looking at creating data entities using JavaBean classes. Create a JavaBean class to create instances of actor. This will be a simple class called Actor with the attributes matching each field in the actor table.
 
Actor 
 | 
actor_id 
first_name 
last_name 
last_update 
 | 
All getters &  setters 
 | 
- Create another class called ActorMgr that holds the following static methods
public static void getAllRecords() 
public static Actor getRecord(int actor_id)
public static boolean insertRecord(Actor actor)
public static boolean updateRecord (Actor actor)
public static boolean deleteRecord (int actor_id)
- The Main method provides the following output:
 
Actor Table 
1 - Display all Row | 2-Get a Row | 3-Add a new row | 4-Update an existing row | 5 - Delete a row   
Select an option : >2 
Enter the actor ID: >100 
100 | SPENCER | DEPP 
Actor Table 
1 - Display all Row | 2-Get a Row | 3-Add a new row | 4-Update an existing row | 5 - Delete a row   
Select an option : >3 
Enter the first name: >Will 
Enter the last name: >Smith 
Success! Created a new row with ID 201.  
Actor Table 
1 - Display all Row | 2-Get a Row | 3-Add a new row | 4-Update an existing row | 5 - Delete a row   
Select an option :> 4 
<Displays a list of actors here> 
Enter the actor ID: >201 
Enter the first name: >William 
Enter the last name: >Smith 
Success! One record was updated.  
<Displays a list of actors here> 
Actor Table 
1 - Display all Row | 2-Get a Row | 3-Add a new row | 4-Update an existing row | 5 - Delete a row   
Select an option : >5 
Enter the actor ID: >201 
Success! One record was deleted.  
<Displays a list of actors here> 
Actor Table 
1 - Display all Row | 2-Get a Row | 3-Add a new row | 4-Update an existing row | 5 - Delete a row   
Select an option : >8 
Invalid Option  
<Terminate> 
 | 
Comments
Post a Comment