Package com.shaft.db
Class DatabaseActions
java.lang.Object
com.shaft.db.DatabaseActions
- Direct Known Subclasses:
SHAFT.DB
-
Nested Class Summary
-
Constructor Summary
ConstructorDescriptionDatabaseActions
(DatabaseActions.DatabaseType databaseType, String ip, String port, String name, String username, String password) This constructor is used for initializing the database variables that are needed to create new connections and perform queriesDatabaseActions
(String customConnectionString) This constructor is used for initializing the database variables that are needed to create new connections and perform queries -
Method Summary
Modifier and TypeMethodDescriptionvoid
int
executeDeleteQuery
(String sql) Executes any DML or DDL statement and returns the result as a ResultSet objectint
executeInsertQuery
(String sql) Executes any DML or DDL statement and returns the result as a ResultSet objectexecuteSelectQuery
(String sql) Executes a SELECT statement and returns the result as a ResultSet objectint
executeUpdateQuery
(String sql) Executes any DML or DDL statement and returns the result as a ResultSet objectstatic String
Returns a string value which represents the data of the target columnstatic DatabaseActions
getInstance
(DatabaseActions.DatabaseType databaseType, String ip, String port, String name, String username, String password) static DatabaseActions
getInstance
(String customConnectionString) static String
Returns a string representation of the provided resultSet objectstatic String
Returns a string value which represents the data of the target rowint
static int
getRowCount
(ResultSet resultSet) Returns the number of rows contained inside the provided resultSet
-
Constructor Details
-
DatabaseActions
public DatabaseActions(DatabaseActions.DatabaseType databaseType, String ip, String port, String name, String username, String password) This constructor is used for initializing the database variables that are needed to create new connections and perform queries- Parameters:
databaseType
- database type that you want to connect with: DatabaseType.MY_SQL ,SQL_SERVER,POSTGRES_SQL.ip
- IP address that has database installation that we need to connect to (e.g. 72.55.136.25)port
- port of database installation on the server (e.g. 3306)name
- database name that you need to connect tousername
- database usernamepassword
- password of database user
-
DatabaseActions
This constructor is used for initializing the database variables that are needed to create new connections and perform queries- Parameters:
customConnectionString
- custom database connection string ex: "jdbc:oracle:thin:@dbServerIP:dbPort:dbName"
-
-
Method Details
-
getInstance
public static DatabaseActions getInstance(DatabaseActions.DatabaseType databaseType, String ip, String port, String name, String username, String password) -
getInstance
-
getResult
Returns a string representation of the provided resultSet object- Parameters:
resultSet
- the object returned as a result of performing a certain database query- Returns:
- a string value which represents the provided resultSet object
-
getRow
Returns a string value which represents the data of the target row- Parameters:
resultSet
- the object returned as a result of performing a certain database querycolumnName
- the name of the column holding the knownCellValueknownCellValue
- a value that the engine searches for under the specified columnName, when that value is found, the row that contains it is read and added to the returned string- Returns:
- a string value which represents the data of the target row
-
getColumn
Returns a string value which represents the data of the target column- Parameters:
resultSet
- the object returned as a result of performing a certain database querycolumnName
- the name of the target column that will be read- Returns:
- a string value which represents the data of the target column
-
getRowCount
Returns the number of rows contained inside the provided resultSet- Parameters:
resultSet
- the object returned as a result of performing a certain database query- Returns:
- an integer value which represents the number of rows contained inside the provided resultSet
-
getResult
-
getRow
-
getColumn
-
getRowCount
public int getRowCount() -
executeSelectQuery
Executes a SELECT statement and returns the result as a ResultSet object- Parameters:
sql
- an SQL statement to be sent to the database, typically a static SQL SELECT statement- Returns:
- a ResultSet object that contains the data produced by the given query; never null
-
executeUpdateQuery
Executes any DML or DDL statement and returns the result as a ResultSet object- Parameters:
sql
- an SQL Data Manipulation Language (DML) ;UPDATE statement, or an SQL statement that returns nothing, such as a DDL statement.- Returns:
- either (1) the row count for SQL Data Manipulation Language (DML) statements or (2) 0 for SQL statements that return nothing
-
executeDDLStatement
-
executeInsertQuery
Executes any DML or DDL statement and returns the result as a ResultSet object- Parameters:
sql
- an SQL Data Manipulation Language (DML) ;INSERT statement, or an SQL statement that returns nothing, such as a DDL statement.- Returns:
- either (1) the row count for SQL Data Manipulation Language (DML) statements or (2) 0 for SQL statements that return nothing
-
executeDeleteQuery
Executes any DML or DDL statement and returns the result as a ResultSet object- Parameters:
sql
- an SQL Data Manipulation Language (DML) ;DELETE statement, or an SQL statement that returns nothing, such as a DDL statement.- Returns:
- either (1) the row count for SQL Data Manipulation Language (DML) statements or (2) 0 for SQL statements that return nothing
-