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
Modifier and TypeFieldDescriptionprivate Connection
Connection
to the serverprivate final String
String
that connects to the serverprivate final String
String
password credentialsprivate final String
String
user name credentials -
Constructor Summary
ConstructorDescriptionDatabaseConnect
(String dbConnectionString, String username, String password) Construct a connection to the database -
Method Summary
Modifier and TypeMethodDescriptionexecuteQuery
(String command) Execute a SQL query.int
executeUpdate
(String command) Handles the UPDATE, INSERT, and DELETE SQL query.void
Initializeconn
and established a connection to the database.
-
Field Details
-
conn
Connection
to the server -
dbConnectionString
String
that connects to the server -
username
String
user name credentials -
password
String
password 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()Initializeconn
and 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
ResultSet
of 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
-