public class ProductDB extends ObjectDB
Constructor and Description |
---|
ProductDB()
Class constructor that fetches the connection to the production database.
|
ProductDB(DatabaseConnection databaseConnection)
Class constructor that stores the given database connection for later use.
|
Modifier and Type | Method and Description |
---|---|
void |
addProduct(Product product)
Add a product in the database
|
java.util.List<Product> |
getAllProducts()
Retrieve all the products from the database
|
Product |
getProduct(java.lang.String productName)
Retrieve the product "productName" from the database
|
static Product |
getProductFromResultSet(java.sql.ResultSet result)
Creates a product from the information in the given ResultSet
|
emptyAllTables, getDatabaseConnection
public ProductDB() throws DatabaseConnectionException
DatabaseConnectionException
public ProductDB(DatabaseConnection databaseConnection)
databaseConnection
- public static Product getProductFromResultSet(java.sql.ResultSet result) throws java.sql.SQLException
result
- java.sql.SQLException
public void addProduct(Product product) throws ProductAlreadyExistsException
product
- ProductAlreadyExistsException
public Product getProduct(java.lang.String productName) throws DatabaseException, NoProductFoundException
productName
- DatabaseException
NoProductFoundException
public java.util.List<Product> getAllProducts() throws DatabaseException
DatabaseException