Package Utils
Class DatabaseConnect
java.lang.Object
Utils.DatabaseConnect
This class establishes a connection to the database and performs queries.
Additionally, it will update the Inventory automatically based on
Additionally, it will update the Inventory automatically based on
Order.- Since:
- 2023-03-07
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ConnectionConnectionto the serverprivate final StringStringthat connects to the serverprivate final StringStringpassword credentialsprivate final StringStringuser name credentials -
Constructor Summary
ConstructorsConstructorDescriptionDatabaseConnect(String dbConnectionString, String username, String password) Construct a connection to the database -
Method Summary
Modifier and TypeMethodDescriptionexecuteQuery(String command) Execute a SQL query.intexecuteUpdate(String command) Handles the UPDATE, INSERT, and DELETE SQL query.voidInitializeconnand established a connection to the database.
-
Field Details
-
conn
Connectionto the server -
dbConnectionString
Stringthat connects to the server -
username
Stringuser name credentials -
password
Stringpassword credentials
-
-
Constructor Details
-
DatabaseConnect
Construct a connection to the database- Parameters:
dbConnectionString- connection Stringusername- user name credentialspassword- password credentials
-
-
Method Details
-
setUpDatabase
public void setUpDatabase()Initializeconnand established a connection to the database. -
executeQuery
Execute a SQL query. This method will NOT handle UPDATE queries. UseexecuteUpdate(String)instead.- Parameters:
command- query to send to database- Returns:
- the
ResultSetof the query
-
executeUpdate
Handles the UPDATE, INSERT, and DELETE SQL query.- Parameters:
command- update to send to the database- Returns:
- the result of the query
-