Class SQLUtil

java.lang.Object
org.cdlib.mrt.utility.SQLUtil

public class SQLUtil extends Object
Framework MySQL common routines
Author:
David Loy
  • Field Details

  • Constructor Details

    • SQLUtil

      public SQLUtil()
  • Method Details

    • cmd

      public static Properties[] cmd(String sqlQuery, Connection connection, LoggerInf logger) throws TException
      Return a row from a table
      Parameters:
      tableName - The name of the table for the insert
      whereProp - Contains a Properties list of name value pairs for setting a select WHERE option
      extractKeys - column names to be extracted
      connection - JDBC connection
      Returns:
      A result object containing status and message

      The row values are available as a Properties object available by calling the DataManagerMYSQL method getRow()
      Note that a status and messagevalues are required on this response

      Throws:
      TException
    • getResult

      public static Properties[] getResult(ResultSet resultSet, LoggerInf logger) throws TException
      Return a row from a table
      Parameters:
      tableName - The name of the table for the insert
      whereProp - Contains a Properties list of name value pairs for setting a select WHERE option
      extractKeys - column names to be extracted
      connection - JDBC connection
      Returns:
      A result object containing status and message

      The row values are available as a Properties object available by calling the DataManagerMYSQL method getRow()
      Note that a status and messagevalues are required on this response

      Throws:
      TException
    • log

      public static void log(String msg)
    • executeSQLRequest

      public static ResultSet executeSQLRequest(String sqlRequest, Connection connection) throws SQLException
      Executes a SQL request against a specified database using the supplied connection
      Parameters:
      connection - Connection object to use for the call
      request - The SQL request to be executed
      Returns:
      A ResultSet object
      Throws:
      SQLException - If the request can not be executed
    • getSelectResults

      public static Properties getSelectResults(ResultSet resultSet) throws Exception
      get a list from elements in list
      Parameters:
      resultSet - jdbc set for extraction
      Returns:
      comma delimited list for Select
      Throws:
      Exception
    • sqlEsc

      public static String sqlEsc(String in)
      escape the special characters needed for sql statements. This is null (ASCII 00), backslash, single and double quotes.
      Parameters:
      in - - the string to process
      Returns:
      the processed string