com.scooterframework.orm.sqldataexpress.connection
Class ConnectionUtil

java.lang.Object
  extended by com.scooterframework.orm.sqldataexpress.connection.ConnectionUtil

public class ConnectionUtil
extends java.lang.Object

ConnectionUtil class


Constructor Summary
ConnectionUtil()
           
 
Method Summary
static void afterConnection(java.sql.Connection connection, DatabaseConnectionContext dcc)
          If the database connection context specifies afterConnection class name, execute the afterConnectionMethodName.
static void beforeConnection(DatabaseConnectionContext dcc)
          If the database connection context specifies beforeConnection class name, execute the beforeConnectionMethodName.
static void checkAutoCommit(java.sql.Connection connection, DatabaseConnectionContext dcc)
          If the database connection context specifies autocommit to be true, set the connection to be auto commit.
static void checkReadonly(java.sql.Connection connection, DatabaseConnectionContext dcc)
          If the database connection context specifies readonly, set the connection to be read only.
static void checkTransactionIsolationLevel(java.sql.Connection connection, DatabaseConnectionContext dcc)
          If the database connection context specifies transaction_isolation_level, set the transaction isolation level of the connection.
static java.sql.Connection createConnection(DataSourceConnectionContext dcc)
          Helper method to create a connection to database with given DataSourceConnectionContext instance.
static java.sql.Connection createConnection(JdbcConnectionContext dcc)
          Helper method to create a connection to database with given JdbcConnectionContext instance.
static java.sql.Connection createConnection(java.lang.String jndiDataSourceName, java.lang.Integer loginTimeout)
          Helper method to create a connection to database with given data source name.
static java.sql.Connection createConnection(java.lang.String driver, java.lang.String url, java.lang.Integer loginTimeout)
          Helper method to create a connection to database with given url, username and password.
static java.sql.Connection createConnection(java.lang.String jndiDataSourceName, java.lang.String username, java.lang.String password, java.lang.Integer loginTimeout)
          Helper method to create a connection to database with given data source name, username and password.
static java.sql.Connection createConnection(java.lang.String driver, java.lang.String url, java.lang.String username, java.lang.String password, java.lang.Integer loginTimeout)
          Helper method to create a connection to database with given url, username and password.
static java.sql.Connection createPooledConnection(JdbcConnectionContext dcc)
          Helper method to create a pooled connection to database with given JdbcConnectionContext instance.
static java.sql.Connection createPooledConnection(java.lang.String connectionName, java.lang.Integer loginTimeout)
          Helper method to create a pooled connection to database with given connection name.
static java.sql.Connection createPooledConnection(java.lang.String connectionName, java.lang.String username, java.lang.String password, java.lang.Integer loginTimeout)
          Helper method to create a pooled connection to database with given connection name.
static java.lang.String getSetRoleStatement(java.util.Properties roles)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConnectionUtil

public ConnectionUtil()
Method Detail

createConnection

public static java.sql.Connection createConnection(DataSourceConnectionContext dcc)
                                            throws CreateConnectionFailureException
Helper method to create a connection to database with given DataSourceConnectionContext instance.

Returns:
Connection
Throws:
CreateConnectionFailureException

createConnection

public static java.sql.Connection createConnection(java.lang.String jndiDataSourceName,
                                                   java.lang.Integer loginTimeout)
                                            throws CreateConnectionFailureException
Helper method to create a connection to database with given data source name.

Returns:
Connection
Throws:
CreateConnectionFailureException

createConnection

public static java.sql.Connection createConnection(java.lang.String jndiDataSourceName,
                                                   java.lang.String username,
                                                   java.lang.String password,
                                                   java.lang.Integer loginTimeout)
Helper method to create a connection to database with given data source name, username and password.

Returns:
Connection
Throws:
CreateConnectionFailureException

createConnection

public static java.sql.Connection createConnection(JdbcConnectionContext dcc)
Helper method to create a connection to database with given JdbcConnectionContext instance.

Returns:
Connection
Throws:
CreateConnectionFailureException

createConnection

public static java.sql.Connection createConnection(java.lang.String driver,
                                                   java.lang.String url,
                                                   java.lang.Integer loginTimeout)
Helper method to create a connection to database with given url, username and password.

Returns:
Connection
Throws:
CreateConnectionFailureException

createConnection

public static java.sql.Connection createConnection(java.lang.String driver,
                                                   java.lang.String url,
                                                   java.lang.String username,
                                                   java.lang.String password,
                                                   java.lang.Integer loginTimeout)
Helper method to create a connection to database with given url, username and password.

Returns:
Connection
Throws:
CreateConnectionFailureException

createPooledConnection

public static java.sql.Connection createPooledConnection(JdbcConnectionContext dcc)
Helper method to create a pooled connection to database with given JdbcConnectionContext instance.

Returns:
Connection
Throws:
CreateConnectionFailureException

createPooledConnection

public static java.sql.Connection createPooledConnection(java.lang.String connectionName,
                                                         java.lang.Integer loginTimeout)
Helper method to create a pooled connection to database with given connection name.

Returns:
Connection
Throws:
CreateConnectionFailureException

createPooledConnection

public static java.sql.Connection createPooledConnection(java.lang.String connectionName,
                                                         java.lang.String username,
                                                         java.lang.String password,
                                                         java.lang.Integer loginTimeout)
Helper method to create a pooled connection to database with given connection name.

Returns:
Connection
Throws:
CreateConnectionFailureException

getSetRoleStatement

public static java.lang.String getSetRoleStatement(java.util.Properties roles)

checkReadonly

public static void checkReadonly(java.sql.Connection connection,
                                 DatabaseConnectionContext dcc)
If the database connection context specifies readonly, set the connection to be read only.

Parameters:
connection - a database connection instance
dcc - a DatabaseConnectionContext instance

checkAutoCommit

public static void checkAutoCommit(java.sql.Connection connection,
                                   DatabaseConnectionContext dcc)
If the database connection context specifies autocommit to be true, set the connection to be auto commit.

Parameters:
connection - a database connection instance
dcc - a DatabaseConnectionContext instance

checkTransactionIsolationLevel

public static void checkTransactionIsolationLevel(java.sql.Connection connection,
                                                  DatabaseConnectionContext dcc)
If the database connection context specifies transaction_isolation_level, set the transaction isolation level of the connection.

Parameters:
connection - a database connection instance
dcc - a DatabaseConnectionContext instance

beforeConnection

public static void beforeConnection(DatabaseConnectionContext dcc)
If the database connection context specifies beforeConnection class name, execute the beforeConnectionMethodName.

Parameters:
dcc - a DatabaseConnectionContext instance

afterConnection

public static void afterConnection(java.sql.Connection connection,
                                   DatabaseConnectionContext dcc)
If the database connection context specifies afterConnection class name, execute the afterConnectionMethodName.

Parameters:
dcc - a DatabaseConnectionContext instance