Class SHAFT.DB
java.lang.Object
com.shaft.db.DatabaseActions
com.shaft.driver.SHAFT.DB
- Enclosing class:
SHAFT
Provides database connectivity and query execution.
Usage example:
SHAFT.DB db = new SHAFT.DB(DatabaseActions.DatabaseType.MY_SQL,
"localhost", "3306", "mydb", "user", "pass");
ResultSet rs = db.executeSelectQuery("SELECT * FROM users");
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class DatabaseActions
DatabaseActions.DatabaseType -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringExtracts the values of a specific column from the result set.static SHAFT.DBgetInstance(DatabaseActions.DatabaseType databaseType, String ip, String port, String name, String username, String password) Factory method for creating a database connection.static SHAFT.DBgetInstance(String customConnectionString) Factory method for creating a database connection with a custom JDBC URL.static StringConverts the entireResultSetinto a string representation.static StringRetrieves a row matching the specified column value.static intgetRowCount(ResultSet resultSet) Returns the total number of rows in the result set.Methods inherited from class DatabaseActions
cleanup, executeDDLStatement, executeDeleteQuery, executeInsertQuery, executeSelectQuery, executeUpdateQuery, getColumn, getResult, getRow, getRowCount
-
Constructor Details
-
DB
Creates a new database connection using a custom JDBC connection string.- Parameters:
customConnectionString- a full JDBC connection URL
-
DB
public DB(DatabaseActions.DatabaseType databaseType, String ip, String port, String name, String username, String password) Creates a new database connection using individual connection parameters.- Parameters:
databaseType- the target database typeip- the host address of the database serverport- the port numbername- the database nameusername- the authentication usernamepassword- the authentication password
-
-
Method Details
-
getInstance
public static SHAFT.DB getInstance(DatabaseActions.DatabaseType databaseType, String ip, String port, String name, String username, String password) Factory method for creating a database connection.- Parameters:
databaseType- the target database typeip- the host address of the database serverport- the port numbername- the database nameusername- the authentication usernamepassword- the authentication password- Returns:
- a new
SHAFT.DBinstance
-
getInstance
-
getResult
-
getColumn
-
getRow
Retrieves a row matching the specified column value.- Parameters:
resultSet- the query result setcolumnName- the column to search inknownCellValue- the value to match- Returns:
- the matching row data as a string
-
getRowCount
Returns the total number of rows in the result set.- Parameters:
resultSet- the query result set- Returns:
- the row count
-