Package org.cdlib.mrt.utility
Class SQLUtil
java.lang.Object
org.cdlib.mrt.utility.SQLUtil
Framework MySQL common routines
- Author:
- David Loy
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Properties[]
cmd
(String sqlQuery, Connection connection, LoggerInf logger) Return a row from a tablestatic ResultSet
executeSQLRequest
(String sqlRequest, Connection connection) Executes a SQL request against a specified database using the supplied connectionstatic Properties[]
Return a row from a tablestatic Properties
getSelectResults
(ResultSet resultSet) get a list from elements in liststatic void
static String
escape the special characters needed for sql statements.
-
Field Details
-
NAME
- See Also:
-
MESSAGE
- See Also:
-
-
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 insertwhereProp
- Contains a Properties list of name value pairs for setting a select WHERE optionextractKeys
- column names to be extractedconnection
- 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
Return a row from a table- Parameters:
tableName
- The name of the table for the insertwhereProp
- Contains a Properties list of name value pairs for setting a select WHERE optionextractKeys
- column names to be extractedconnection
- 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
-
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 callrequest
- The SQL request to be executed- Returns:
- A ResultSet object
- Throws:
SQLException
- If the request can not be executed
-
getSelectResults
get a list from elements in list- Parameters:
resultSet
- jdbc set for extraction- Returns:
- comma delimited list for Select
- Throws:
Exception
-
sqlEsc
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
-