Class SHAFT.DB

Enclosing class:
SHAFT

public static class SHAFT.DB extends DatabaseActions
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:
  • Constructor Details

    • DB

      public DB(String customConnectionString)
      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 type
      ip - the host address of the database server
      port - the port number
      name - the database name
      username - the authentication username
      password - 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 type
      ip - the host address of the database server
      port - the port number
      name - the database name
      username - the authentication username
      password - the authentication password
      Returns:
      a new SHAFT.DB instance
    • getInstance

      public static SHAFT.DB getInstance(String customConnectionString)
      Factory method for creating a database connection with a custom JDBC URL.
      Parameters:
      customConnectionString - a full JDBC connection URL
      Returns:
      a new SHAFT.DB instance
    • getResult

      public static String getResult(ResultSet resultSet)
      Converts the entire ResultSet into a string representation.
      Parameters:
      resultSet - the query result set
      Returns:
      all result data as a string
    • getColumn

      public static String getColumn(ResultSet resultSet, String columnName)
      Extracts the values of a specific column from the result set.
      Parameters:
      resultSet - the query result set
      columnName - the name of the column to extract
      Returns:
      the column values as a string
    • getRow

      public static String getRow(ResultSet resultSet, String columnName, String knownCellValue)
      Retrieves a row matching the specified column value.
      Parameters:
      resultSet - the query result set
      columnName - the column to search in
      knownCellValue - the value to match
      Returns:
      the matching row data as a string
    • getRowCount

      public static int getRowCount(ResultSet resultSet)
      Returns the total number of rows in the result set.
      Parameters:
      resultSet - the query result set
      Returns:
      the row count