uPortal 2.4.1
API Documentation

org.jasig.portal
Class RDBMServices

java.lang.Object
  extended byorg.jasig.portal.RDBMServices

public class RDBMServices
extends java.lang.Object

Provides relational database access and helper methods. A static routine determins if the database/driver supports prepared statements and/or outer joins.

Version:
$Revision: 1.27.2.1 $
Author:
Ken Weiner, kweiner@unicon.net, George Lindholm, george.lindholm@ubc.ca

Nested Class Summary
static interface RDBMServices.IJoinQueryString
           
static class RDBMServices.JdbcDb
           
static class RDBMServices.JoinQueryString
           
static class RDBMServices.OracleDb
           
static class RDBMServices.PostgreSQLDb
           
static class RDBMServices.PreparedStatement
          Wrapper for/Emulator of PreparedStatement class
 
Field Summary
static RDBMServices.IJoinQueryString joinQuery
           
static java.lang.String PERSON_DB
           
static java.lang.String PORTAL_DB
           
static int RETRY_COUNT
           
static boolean supportsOuterJoins
           
static boolean supportsTransactions
           
 
Constructor Summary
RDBMServices()
           
 
Method Summary
static void closePreparedStatement(java.sql.PreparedStatement ps)
          Close a PreparedStatement
static void closePreparedStatement(RDBMServices.PreparedStatement ps)
          Close a PreparedStatement
static void closeResultSet(java.sql.ResultSet rs)
          Close a ResultSet
static void closeStatement(java.sql.Statement st)
          Close a Statement
static void commit(java.sql.Connection connection)
          Commit pending transactions
static java.lang.String dbFlag(boolean flag)
          Return DB format of a boolean.
static boolean dbFlag(java.lang.String flag)
          Return boolean value of DB flag, "Y" or "N".
static java.sql.Connection getConnection()
          Gets a database connection to the portal database.
static java.sql.Connection getConnection(java.lang.String dbName)
          Returns a connection produced by a DataSource found in the JNDI context.
static java.lang.String getJdbcDriver()
          Get the JDBC driver
static java.lang.String getJdbcUrl()
          Get the JDBC connection URL
static java.lang.String getJdbcUser()
          Get the JDBC user
static void releaseConnection(java.sql.Connection con)
          Releases database connection
static void rollback(java.sql.Connection connection)
          rollback unwanted changes to the database
static void setAutoCommit(java.sql.Connection connection, boolean autocommit)
          Set auto commit state for the connection
static java.lang.String sqlEscape(java.lang.String sql)
          Make a string SQL safe
static java.lang.String sqlTimeStamp()
          SQL format of current time
static java.lang.String sqlTimeStamp(java.util.Date date)
          SQL format a Date
static java.lang.String sqlTimeStamp(long date)
          SQL format a long timestamp
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RETRY_COUNT

public static int RETRY_COUNT

supportsOuterJoins

public static boolean supportsOuterJoins

supportsTransactions

public static boolean supportsTransactions

joinQuery

public static RDBMServices.IJoinQueryString joinQuery

PORTAL_DB

public static final java.lang.String PORTAL_DB
See Also:
Constant Field Values

PERSON_DB

public static final java.lang.String PERSON_DB
See Also:
Constant Field Values
Constructor Detail

RDBMServices

public RDBMServices()
Method Detail

getConnection

public static java.sql.Connection getConnection(java.lang.String dbName)
Returns a connection produced by a DataSource found in the JNDI context. The DataSource should be configured and loaded into JNDI by the J2EE container.

Parameters:
dbName - the database name which will be retrieved from the JNDI context relative to "jdbc/"
Returns:
a database Connection object or null if no Connection

getConnection

public static java.sql.Connection getConnection()
Gets a database connection to the portal database. This method will first try to get the connection by looking in the JNDI context if org.jasig.portal.RDBMServices.get_datasource_from_jndi property is enabled. If not enabled, the Connection will be produced by DriverManager.getConnection(). This method should probably be deprecated since obtaining connections from JNDI is the preferred way to do it according to J2EE.

Returns:
a database Connection object

releaseConnection

public static void releaseConnection(java.sql.Connection con)
Releases database connection

Parameters:
con - a database Connection object

closePreparedStatement

public static void closePreparedStatement(java.sql.PreparedStatement ps)
Close a PreparedStatement

Parameters:
ps - a database PreparedStatement object

closePreparedStatement

public static void closePreparedStatement(RDBMServices.PreparedStatement ps)
Close a PreparedStatement

Parameters:
ps - a database PreparedStatement object

closeResultSet

public static void closeResultSet(java.sql.ResultSet rs)
Close a ResultSet

Parameters:
rs - a database ResultSet object

closeStatement

public static void closeStatement(java.sql.Statement st)
Close a Statement

Parameters:
st - a database Statement object

getJdbcDriver

public static java.lang.String getJdbcDriver()
Get the JDBC driver

Returns:
the JDBC driver

getJdbcUrl

public static java.lang.String getJdbcUrl()
Get the JDBC connection URL

Returns:
the JDBC connection URL

getJdbcUser

public static java.lang.String getJdbcUser()
Get the JDBC user

Returns:
the JDBC connection URL

commit

public static final void commit(java.sql.Connection connection)
                         throws java.sql.SQLException
Commit pending transactions

Parameters:
connection -
Throws:
java.sql.SQLException

setAutoCommit

public static final void setAutoCommit(java.sql.Connection connection,
                                       boolean autocommit)
                                throws java.sql.SQLException
Set auto commit state for the connection

Parameters:
connection -
autocommit -
Throws:
java.sql.SQLException

rollback

public static final void rollback(java.sql.Connection connection)
                           throws java.sql.SQLException
rollback unwanted changes to the database

Parameters:
connection -
Throws:
java.sql.SQLException

dbFlag

public static final java.lang.String dbFlag(boolean flag)
Return DB format of a boolean. "Y" for true and "N" for false.

Parameters:
flag - true or false
Returns:
either "Y" or "N"

dbFlag

public static final boolean dbFlag(java.lang.String flag)
Return boolean value of DB flag, "Y" or "N".

Parameters:
flag - either "Y" or "N"
Returns:
boolean true or false

sqlTimeStamp

public static final java.lang.String sqlTimeStamp()
SQL format of current time

Returns:
SQL TimeStamp

sqlTimeStamp

public static final java.lang.String sqlTimeStamp(long date)
SQL format a long timestamp

Parameters:
date -
Returns:
SQL TimeStamp

sqlTimeStamp

public static final java.lang.String sqlTimeStamp(java.util.Date date)
SQL format a Date

Parameters:
date -
Returns:
SQL TimeStamp or "NULL" if date is null

sqlEscape

public static final java.lang.String sqlEscape(java.lang.String sql)
Make a string SQL safe

Parameters:
sql -
Returns:
SQL safe string

uPortal 2.4.1
API Documentation