| |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Utility methods for SQL statements.
Method Summary | |
static void | closeResultSet(ResultSet rs) Close the given JDBC ResultSet and ignore any thrown exception. |
static void | closeStatement(Statement stmt) Close the given JDBC Statement and ignore any thrown exception. |
static int | countParameterPlaceholders(String str, char placeholder, char delim) Count the occurrences of the character placeholder in an SQL string str . |
static boolean | isNumeric(int sqlType) Check that a SQL type is numeric |
static int | translateType(int sqlType) Translate a SQL type into one of a few values. |
Method Detail |
public static void closeResultSet(ResultSet rs)
public static void closeStatement(Statement stmt)
public static int countParameterPlaceholders(String str, char placeholder, char delim)
placeholder
in an SQL string str
.
The character placeholder
is not counted if it appears within a literal as determined
by the delim
that is passed in.
Examples : if the delimiter is the single quote, and the character to count the occurrences of is the question mark, then
The big ? 'bad wolf?'
gives a count of one
The big ?? bad wolf
gives a count of two
The big 'ba''ad?' ? wolf
gives a count of one
The grammar of the string passed in should obey the rules of the JDBC spec which is close to no rules at all. One placeholder per parameter and it should be valid SQL for the target database.
public static boolean isNumeric(int sqlType)
true
if the type is numeric,
false
otherwisepublic static int translateType(int sqlType)
| |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |