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

net.java.ao.sql.SqlUtils Maven / Gradle / Ivy

package net.java.ao.sql;

import com.google.common.base.Function;
import net.java.ao.Common;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 *
 */
public final class SqlUtils
{
    public static final Pattern WHERE_CLAUSE = Pattern.compile("(\\w+)(?=\\s*((=|!=|>|<|<>|(? fieldNameProcessor)
    {
        final Matcher matcher = WHERE_CLAUSE.matcher(where);
        final StringBuffer  sb = new StringBuffer();
        while (matcher.find())
        {
            matcher.appendReplacement(sb, fieldNameProcessor.apply(matcher.group()));
        }
        matcher.appendTail(sb);
        return sb.toString();
    }

    public static void closeQuietly(Connection connection)
    {
        Common.closeQuietly(connection);
    }

    public static void closeQuietly(Statement statement)
    {
        Common.closeQuietly(statement);
    }

    public static void closeQuietly(ResultSet resultSet)
    {
        Common.closeQuietly(resultSet);
    }

    public static void closeQuietly(Statement st, Connection c)
    {
        closeQuietly(st);
        closeQuietly(c);
    }

    public static void closeQuietly(ResultSet rs, Statement st, Connection c)
    {
        closeQuietly(rs);
        closeQuietly(st, c);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy