|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jasig.portal.RDBMServices
public class RDBMServices
Provides relational database access and helper methods. A static routine determines if the database/driver supports prepared statements and/or outer joins.
This class provides database access as a service. Via the class, uPortal code can obtain a connection to the core uPortal database as well as to other databases available via JNDI. (Doing that JNDI lookup directly allows your code to avoid dependence upon this class.) This class provides traditional getConnection() methods as well as static covers for getting a reference to the backing DataSource.
This class also provides helper methods for manipulating connections. Mostof the methods are wrappers around methods on the underlying Connection that handle (log and swallow) the SQLExceptions that the underlying methods declare to be thrown (these helpers also catch and log RuntimeExceptions encountered). They provide an alternative to trying and catching those methods using the JDBC APIs directly.
| Field Summary | |
|---|---|
static String |
PORTAL_DB
Name of the default portal database expected in the Spring application context |
static String |
PORTAL_DB_METADATA
Name of the IDatabaseMetadata expected in the Spring application context |
| Constructor Summary | |
|---|---|
RDBMServices()
|
|
| Method Summary | |
|---|---|
static void |
closeResultSet(ResultSet rs)
Close a ResultSet |
static void |
closeStatement(Statement st)
Close a Statement |
static void |
commit(Connection connection)
Commit pending transactions. |
static String |
dbFlag(boolean flag)
Return DB format of a boolean. |
static boolean |
dbFlag(String flag)
Return boolean value of DB flag, "Y" or "N". |
static int |
getActiveConnectionCount()
|
static Connection |
getConnection()
Deprecated. Where possible code should be injected with a DataSource object via the Spring application context |
static Connection |
getConnection(String dbName)
Deprecated. Where possible code should be injected with a DataSource object via the Spring application context |
static DataSource |
getDataSource()
Deprecated. Where possible code should be injected with a DataSource object via the Spring application context |
static DataSource |
getDataSource(String name)
Deprecated. Where possible code should be injected with a DataSource object via the Spring application context |
static IDatabaseMetadata |
getDbMetaData()
Deprecated. Use the bean named PortalDB.metadata instead |
static String |
getJdbcDriver()
Returns the name of the JDBC driver being used for the default uPortal database connections. |
static String |
getJdbcUrl()
Gets the JDBC URL of the default uPortal database connections. |
static String |
getJdbcUser()
Get the username under which we are connecting for the default uPortal database connections. |
static MovingAverageSample |
getLastDatabase()
|
static int |
getMaxConnectionCount()
|
static void |
releaseConnection(Connection con)
Deprecated. Where possible code should be injected with a DataSource object via the Spring application context |
static void |
rollback(Connection connection)
rollback unwanted changes to the database |
static void |
setAutoCommit(Connection connection,
boolean autocommit)
Set auto commit state for the connection. |
static String |
sqlEscape(String sql)
Make a string SQL safe |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String PORTAL_DB
public static final String PORTAL_DB_METADATA
IDatabaseMetadata expected in the Spring application context
| Constructor Detail |
|---|
public RDBMServices()
| Method Detail |
|---|
@Deprecated public static DataSource getDataSource()
DataSource object via the Spring application context
RuntimeException - on failure@Deprecated public static DataSource getDataSource(String name)
DataSource object via the Spring application context
#JNDI_RETRY_TIME to reduce
JNDI overhead and log spam.
There are two ways in which we handle the core uPortal DataSource
specially.
We determine and remember metadata in an DbMetaData object for the core
uPortal DataSource. We do not compute this DbMetaData for any other
DataSource.
We fall back on using rdbm.properties to construct our core uPortal
DataSource in the case where we cannot find it from JNDI. If the portal
property org.jasig.portal.RDBMServices.getDatasourceFromJNDI is true,
we first
first try to get the connection by looking in the
JNDI context for the name defined by the portal property
org.jasig.portal.RDBMServices.PortalDatasourceJndiName .
If we were not configured to check JNDI or we didn't find it in JNDI having
checked, we then fall back on rdbm.properties.
name - The name of the DataSource to get.
null if one cannot be found.public static int getActiveConnectionCount()
public static int getMaxConnectionCount()
public static MovingAverageSample getLastDatabase()
@Deprecated public static Connection getConnection()
DataSource object via the Spring application context
DataAccessException - if unable to return a connection@Deprecated public static Connection getConnection(String dbName)
DataSource object via the Spring application context
dbName - the database name which will be retrieved from
the JNDI context relative to "jdbc/"
null if no Connection@Deprecated public static void releaseConnection(Connection con)
DataSource object via the Spring application context
con - a database Connection objectpublic static void closeResultSet(ResultSet rs)
rs - a database ResultSet objectpublic static void closeStatement(Statement st)
st - a database Statement objectpublic static final void commit(Connection connection)
connection -
public static final void setAutoCommit(Connection connection,
boolean autocommit)
connection - autocommit -
public static final void rollback(Connection connection)
throws SQLException
connection -
SQLExceptionpublic static String getJdbcDriver()
public static String getJdbcUrl()
public static String getJdbcUser()
public static final String dbFlag(boolean flag)
flag - true or false
public static final boolean dbFlag(String flag)
flag - either "Y" or "N"
public static final String sqlEscape(String sql)
sql -
@Deprecated public static IDatabaseMetadata getDbMetaData()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||