001 package com.mockrunner.jdbc; 002 003 import java.sql.ResultSet; 004 import java.sql.SQLException; 005 006 /** 007 * Simple util class for SQL statements 008 */ 009 public class SQLUtil 010 { 011 /** 012 * Returns if the specified SQL string is a select, i.e. 013 * contains the string <i>select</i> (case insensitive). 014 * @param sql the SQL string 015 * @return <code>true</code> if the specified SQL string is a select 016 */ 017 public static boolean isSelect(String sql) 018 { 019 sql = sql.toLowerCase(); 020 return (-1 != sql.indexOf("select")); 021 } 022 023 /** 024 * Throws an <code>SQLException</code> if the specified 025 * <code>fetchDirection</code> is invalid 026 * @param fetchDirection the fetch direction 027 */ 028 public static void checkFetchDirection(int fetchDirection) throws SQLException 029 { 030 if(fetchDirection != ResultSet.FETCH_FORWARD && fetchDirection != ResultSet.FETCH_REVERSE && fetchDirection != ResultSet.FETCH_UNKNOWN) 031 { 032 throw new SQLException("fetchDirection must be either FETCH_FORWARD, FETCH_REVERSE or FETCH_UNKNOWN"); 033 } 034 } 035 }