All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.mockrunner.jdbc.SQLUtil Maven / Gradle / Ivy

Go to download

Mockrunner is a lightweight framework for unit testing applications in the J2EE environment. It supports servlets, filters, tag classes and Struts actions. It includes a JDBC a JMS and a JCA test framework and can be used to test EJB based applications.

The newest version!
package com.mockrunner.jdbc;

import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * Simple util class for SQL statements
 */
public class SQLUtil
{
    /**
     * Returns if the specified SQL string is a select, i.e.
     * contains the string select (case insensitive).
     * @param sql the SQL string
     * @return true if the specified SQL string is a select
     */
    public static boolean isSelect(String sql)
    {
        sql = sql.toLowerCase();
        return (-1 != sql.indexOf("select"));
    }
    
    /**
     * Throws an SQLException if the specified 
     * fetchDirection is invalid
     * @param fetchDirection the fetch direction
     */
    public static void checkFetchDirection(int fetchDirection) throws SQLException
    {
        if(fetchDirection != ResultSet.FETCH_FORWARD && fetchDirection != ResultSet.FETCH_REVERSE && fetchDirection != ResultSet.FETCH_UNKNOWN)
        {
            throw new SQLException("fetchDirection must be either FETCH_FORWARD, FETCH_REVERSE or FETCH_UNKNOWN");
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy