01: package com.mockrunner.jdbc;
02:
03: import java.sql.ResultSet;
04: import java.sql.SQLException;
05:
06: /**
07: * Simple util class for SQL statements
08: */
09: public class SQLUtil {
10: /**
11: * Returns if the specified SQL string is a select, i.e.
12: * contains the string <i>select</i> (case insensitive).
13: * @param sql the SQL string
14: * @return <code>true</code> if the specified SQL string is a select
15: */
16: public static boolean isSelect(String sql) {
17: sql = sql.toLowerCase();
18: return (-1 != sql.indexOf("select"));
19: }
20:
21: /**
22: * Throws an <code>SQLException</code> if the specified
23: * <code>fetchDirection</code> is invalid
24: * @param fetchDirection the fetch direction
25: */
26: public static void checkFetchDirection(int fetchDirection)
27: throws SQLException {
28: if (fetchDirection != ResultSet.FETCH_FORWARD
29: && fetchDirection != ResultSet.FETCH_REVERSE
30: && fetchDirection != ResultSet.FETCH_UNKNOWN) {
31: throw new SQLException(
32: "fetchDirection must be either FETCH_FORWARD, FETCH_REVERSE or FETCH_UNKNOWN");
33: }
34: }
35: }
|