Package edu.pdx.cs.joy.phonebill
Class PhoneBillDAO
java.lang.Object
edu.pdx.cs.joy.phonebill.PhoneBillDAO
A Data Access Object (DAO) for persisting PhoneBill instances to a database.
This is a simple example to demonstrate basic JDBC operations.
Students can expand this to include PhoneCall persistence and more
sophisticated query capabilities.
-
Constructor Summary
ConstructorsConstructorDescriptionPhoneBillDAO(Connection connection) Creates a new PhoneBillDAO with the specified database connection. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcreateTable(Connection connection) Creates the customers table in the database.findByCustomer(String customerName) Finds a PhoneBill by customer name.static voidvoidSaves a PhoneBill to the database.
-
Constructor Details
-
PhoneBillDAO
Creates a new PhoneBillDAO with the specified database connection.- Parameters:
connection- the database connection to use
-
-
Method Details
-
createTable
Creates the customers table in the database.- Parameters:
connection- the database connection to use- Throws:
SQLException- if a database error occurs
-
save
Saves a PhoneBill to the database.- Parameters:
bill- the phone bill to save- Throws:
SQLException- if a database error occurs
-
findByCustomer
Finds a PhoneBill by customer name.- Parameters:
customerName- the customer name to search for- Returns:
- the PhoneBill for the customer, or null if not found
- Throws:
SQLException- if a database error occurs
-
main
- Throws:
SQLException
-