com.massimo.tools.scriptrunner.utils
Class DBHelper

java.lang.Object
  extended by com.massimo.tools.scriptrunner.utils.DBHelper

public class DBHelper
extends Object

Simple database utilities. Hopefully these are DBMS independent, using standard JDBC calls.


Constructor Summary
DBHelper()
           
 
Method Summary
static int executeIntFunction(Connection connection, String sql, Object[] binds)
           
static int executeIntQuery(Connection connection, String sql, Object[] binds)
           
static DatabaseType getDatabaseType(Connection cxn)
           
static DatabaseType getDatabaseType(String className)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DBHelper

public DBHelper()
Method Detail

executeIntFunction

public static int executeIntFunction(Connection connection,
                                     String sql,
                                     Object[] binds)
                              throws SQLException
Parameters:
connection -
sql - Text of the SQL statement to execute. This must return an integer in the first bind variable.
binds - In bind variable values, in the order to be set.
Returns:
The returned integer value, or Integer.MIN_VALUE if a Number is not returned
Throws:
SQLException

executeIntQuery

public static int executeIntQuery(Connection connection,
                                  String sql,
                                  Object[] binds)
                           throws SQLException
Parameters:
connection -
sql - Text of the SQL statement to execute. This must return an integer in the first column.
binds - Bind variable values, in the order to be set.
Returns:
The returned integer value, or Integer.MIN_VALUE if no rows are returned
Throws:
SQLException

getDatabaseType

public static DatabaseType getDatabaseType(Connection cxn)
Parameters:
cxn -
Returns:
A guess at the DBMS from the connection class name

getDatabaseType

public static DatabaseType getDatabaseType(String className)
Parameters:
className -
Returns:
A guess at the DBMS from the class name