|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.xmlserv.util.SQLUtil
A collection of static helper methods for handling SQL statements.
Field Summary | |
static char[] |
chars
The characters to escape/unescape using escape/unscape utility methods. |
Method Summary | |
static java.lang.String |
boolean2String(boolean flag)
Convert a Boolean value to an SQL string representation. |
static java.lang.String |
checkID(java.sql.Connection con,
java.lang.String tablename,
java.lang.String id)
Check if the given value is a number and exists in the given table as an ID value. |
static java.lang.String |
escape(java.lang.String input)
Add backslashes before offensive characters to make the string usable in an SQL query. Specifically the following transformations are done: The following characters are prefixed with a backslash: ' ; \ |
static java.lang.String[] |
escape(java.lang.String[] input)
|
static java.lang.String |
escape(java.lang.StringBuffer work)
Avoid thread concurrency problems: work StringBuffer must be provided by caller. |
static org.jdom.Element |
getElement(java.sql.ResultSet rs,
java.lang.String fieldname)
See above. |
static org.jdom.Element |
getElement(java.sql.ResultSet rs,
java.lang.String fieldname,
java.lang.String tagname)
Parse the given field in the ResultSet, returning the named (firstlevel) child as a detached org.jdom.Element to be inserted into another JDOM tree. |
static java.lang.String |
getID(java.sql.Connection con,
java.lang.String table,
java.lang.String column,
java.lang.String value)
Get the ID for the given name. |
static java.lang.String |
md5(java.lang.String input)
Add missing MD5() function for Postgres. |
static java.lang.String |
unescape(java.lang.String input)
Remove backslashes added by escape(). |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static char[] chars
Method Detail |
public static java.lang.String escape(java.lang.String input)
public static java.lang.String escape(java.lang.StringBuffer work)
input
- The string to process (as a StringBuffer).public static java.lang.String[] escape(java.lang.String[] input)
public static java.lang.String unescape(java.lang.String input)
input
- The input string to unescape.public static java.lang.String md5(java.lang.String input)
input
- The String to calculate the hash for.public static org.jdom.Element getElement(java.sql.ResultSet rs, java.lang.String fieldname, java.lang.String tagname) throws java.sql.SQLException, org.jdom.JDOMException, XMLServException
rs
- The ResulktSet to read data from.fieldname
- The name of the datafield.tagname
- The name of the tag to extract. If null, the root Element is returned.java.sql.SQLException
- Upon error reading from the ResultSet.org.jdom.JDOMException
- Upon an error parsing the field content.public static org.jdom.Element getElement(java.sql.ResultSet rs, java.lang.String fieldname) throws java.sql.SQLException, org.jdom.JDOMException, XMLServException
getElement(ResultSet, String, String)
public static java.lang.String checkID(java.sql.Connection con, java.lang.String tablename, java.lang.String id) throws java.sql.SQLException, java.lang.NumberFormatException
con
- The DB connection object.tablename
- The name of the table.id
- The ID to search for.java.sql.SQLException
- If the ID does not exist or on other SQL error.java.lang.NumberFormatException
- If the given String cannot be converted to a number.public static java.lang.String getID(java.sql.Connection con, java.lang.String table, java.lang.String column, java.lang.String value) throws java.sql.SQLException
con
- A Connection.table
- The tablename.column
- The fieldname to match (must be a unique column).value
- The value to search for.java.sql.SQLException
- A DB error occurred.public static java.lang.String boolean2String(boolean flag)
flag
- The value to convert.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |