org.mentabean.util
Class SQLUtils

java.lang.Object
  extended by org.mentabean.util.SQLUtils

public class SQLUtils
extends Object


Field Summary
static String FOREIGN_KEY_VIOLATED_STATE
           
static String UNIQUE_KEY_VIOLATED_STATE
           
 
Constructor Summary
SQLUtils()
           
 
Method Summary
static void beginTransaction(Connection conn)
           
static boolean checkIfTableExists(Connection conn, String tableName)
           
static void close(Connection conn)
           
static void close(ResultSet rset, Statement stmt)
           
static void close(ResultSet rset, Statement stmt, Connection conn)
           
static void close(Statement stmt)
           
static void close(Statement stmt, Connection conn)
           
static void commitTransaction(Connection conn)
           
static void executeScript(Connection conn, String file, String charset)
           
static int fillStatement(PreparedStatement stmt, Object... params)
          Fill the given PreparedStatement object with the specified parameters.

Note that this method uses the setObject method which depends of a specified JDBC driver implementation to work properly.
static int fillStatementIndx(PreparedStatement stmt, int indx, Object... params)
          Fill the given PreparedStatement object with the specified parameters starting at indx position.

Note that this method uses the setObject method which depends of a specified JDBC driver implementation to work properly.
static Limit lim(int x)
           
static OrderBy orderByAsc(Object field)
           
static OrderBy orderByDesc(Object field)
           
static PreparedStatement prepare(Connection conn, String query, Object... params)
          Prepare a statement (PreparedStatement) with the query and set the parameters.
static void rollbackTransaction(Connection conn)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNIQUE_KEY_VIOLATED_STATE

public static final String UNIQUE_KEY_VIOLATED_STATE
See Also:
Constant Field Values

FOREIGN_KEY_VIOLATED_STATE

public static final String FOREIGN_KEY_VIOLATED_STATE
See Also:
Constant Field Values
Constructor Detail

SQLUtils

public SQLUtils()
Method Detail

executeScript

public static void executeScript(Connection conn,
                                 String file,
                                 String charset)

checkIfTableExists

public static boolean checkIfTableExists(Connection conn,
                                         String tableName)

close

public static void close(Statement stmt)

close

public static void close(ResultSet rset,
                         Statement stmt)

close

public static void close(Statement stmt,
                         Connection conn)

close

public static void close(Connection conn)

close

public static void close(ResultSet rset,
                         Statement stmt,
                         Connection conn)

fillStatement

public static int fillStatement(PreparedStatement stmt,
                                Object... params)
Fill the given PreparedStatement object with the specified parameters.

Note that this method uses the setObject method which depends of a specified JDBC driver implementation to work properly.

Parameters:
stmt - - The PreparedStatement object
params - - Values that will be added in statement
Returns:
The last index added plus 1. It can be useful for continuous statement filling operations.
See Also:
fillStatementIndx(PreparedStatement, int, Object...), PreparedStatement.setObject(int, Object)

fillStatementIndx

public static int fillStatementIndx(PreparedStatement stmt,
                                    int indx,
                                    Object... params)
Fill the given PreparedStatement object with the specified parameters starting at indx position.

Note that this method uses the setObject method which depends of a specified JDBC driver implementation to work properly.

Parameters:
stmt - - The PreparedStatement object
indx - - Initial index for setting attributes in statement
params - - Values that will be added in statement
Returns:
The next index (last added plus 1). It can be useful for continuous statement filling operations.
See Also:
fillStatement(PreparedStatement, Object...), PreparedStatement.setObject(int, Object)

prepare

public static PreparedStatement prepare(Connection conn,
                                        String query,
                                        Object... params)
                                 throws SQLException
Prepare a statement (PreparedStatement) with the query and set the parameters.

Parameters:
conn - the connection
query - the query to prepare
params - the parameters to set in the query
Returns:
the statement ready to be executed
Throws:
SQLException

orderByAsc

public static OrderBy orderByAsc(Object field)

orderByDesc

public static OrderBy orderByDesc(Object field)

lim

public static Limit lim(int x)

beginTransaction

public static void beginTransaction(Connection conn)

commitTransaction

public static void commitTransaction(Connection conn)

rollbackTransaction

public static void rollbackTransaction(Connection conn)


Copyright © 2013. All Rights Reserved.