|
Compoze Software, Inc. | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.compoze.ejb.DatabaseConnectionHelper
This is a helper class to create database connections and perform common database interactions.
Constructor Summary | |
DatabaseConnectionHelper()
|
Method Summary | |
static java.sql.Connection |
getBeanDBConnection(java.lang.ClassLoader classLoader)
Deprecated. Use getBeanDBConnection(com.compoze.security.User,ClassLoader) instead so that
information will be available to select the DataSource
at runtime |
static java.sql.Connection |
getBeanDBConnection(User caller)
Gets the database connection from the database connection factory registered in the current service registry. |
static java.sql.Connection |
getBeanDBConnection(User caller,
java.lang.ClassLoader classLoader)
Gets the database connection from the database connection factory registered in the current service registry. |
static com.compoze.ejb.persistence.database.IIdentifierFormat |
getIdentifierFormat()
Gets a formatted, comma separated column list from the specified list of columns. |
static java.io.InputStream |
getInputStreamToObject(java.lang.Object obj)
Gets an InputStream which reads the serialized data of an object. |
static java.lang.Object |
getObjectFromInputStream(java.io.InputStream is)
Instantiates an object from an InputStream to its serialized data. |
static java.lang.String |
getQuotedColumn(java.lang.String column)
Gets a formatted, comma separated column list from the specified list of columns. |
static java.lang.String |
getQuotedColumn(java.lang.String[] columns)
Gets a formatted, comma separated column list from the specified list of columns. |
static java.lang.String |
getQuotedColumn(java.lang.String[] columns,
com.compoze.ejb.persistence.database.IIdentifierFormat identifierFormat)
Gets a formatted, comma separated column list from the specified list of columns. |
static java.lang.String |
getQuotedColumn(java.lang.String column,
com.compoze.ejb.persistence.database.IIdentifierFormat identifierFormat)
Gets a formatted, comma separated column list from the specified list of columns. |
static java.lang.Object |
getSerializableObject(java.sql.ResultSet rs,
int iParameterIndex)
Gets a serializable object from a ResultSet . |
static java.lang.Object |
getSerializableObject(java.sql.ResultSet rs,
java.lang.String sColumnName)
Gets a serializable object from a ResultSet . |
static void |
setSerializableObject(java.sql.PreparedStatement pstmt,
int iColumn,
java.lang.Object obj)
Sets a serializable object in a prepared statement using setBinaryStream() . |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public DatabaseConnectionHelper()
Method Detail |
public static java.sql.Connection getBeanDBConnection(User caller) throws javax.naming.NamingException, java.sql.SQLException, java.lang.reflect.InvocationTargetException, java.lang.ClassNotFoundException, java.lang.NoSuchMethodException, java.lang.IllegalAccessException, java.lang.InstantiationException
caller
- the caller or null
to use default settingsjavax.naming.NamingException
- if a naming exception occurredjava.sql.SQLException
- if an SQL exception occurredjava.lang.reflect.InvocationTargetException
- if a method could not be invoked using introspectionjava.lang.ClassNotFoundException
- if a class could not be found using introspectionjava.lang.NoSuchMethodException
- if the constructor on the database connection factory
could not be invokedjava.lang.IllegalAccessException
- if a field or method could not be accessed
using introspectionjava.lang.InstantiationException
- if the database connection factory could not be
instantiatedIDatabaseConnectionFactory
,
EjbServiceRegistry
public static java.sql.Connection getBeanDBConnection(java.lang.ClassLoader classLoader) throws javax.naming.NamingException, java.sql.SQLException, java.lang.reflect.InvocationTargetException, java.lang.ClassNotFoundException, java.lang.NoSuchMethodException, java.lang.IllegalAccessException, java.lang.InstantiationException
getBeanDBConnection(com.compoze.security.User,ClassLoader)
instead so that
information will be available to select the DataSource
at runtime
classLoader
- the class loader to look for class injavax.naming.NamingException
- if a naming exception occurredjava.sql.SQLException
- if an SQL exception occurredjava.lang.reflect.InvocationTargetException
- if a method could not be invoked using introspectionjava.lang.ClassNotFoundException
- if a class could not be found using introspectionjava.lang.NoSuchMethodException
- if the constructor on the database connection factory
could not be invokedjava.lang.IllegalAccessException
- if a field or method could not be accessed
using introspectionjava.lang.InstantiationException
- if the database connection factory could not be
instantiatedIDatabaseConnectionFactory
,
EjbServiceRegistry
public static java.sql.Connection getBeanDBConnection(User caller, java.lang.ClassLoader classLoader) throws javax.naming.NamingException, java.sql.SQLException, java.lang.reflect.InvocationTargetException, java.lang.ClassNotFoundException, java.lang.NoSuchMethodException, java.lang.IllegalAccessException, java.lang.InstantiationException
caller
- the callerclassLoader
- the class loader to look for class injavax.naming.NamingException
- if a naming exception occurredjava.sql.SQLException
- if an SQL exception occurredjava.lang.reflect.InvocationTargetException
- if a method could not be invoked using introspectionjava.lang.ClassNotFoundException
- if a class could not be found using introspectionjava.lang.NoSuchMethodException
- if the constructor on the database connection factory
could not be invokedjava.lang.IllegalAccessException
- if a field or method could not be accessed
using introspectionjava.lang.InstantiationException
- if the database connection factory could not be
instantiatedIDatabaseConnectionFactory
,
EjbServiceRegistry
public static void setSerializableObject(java.sql.PreparedStatement pstmt, int iColumn, java.lang.Object obj) throws java.io.IOException, java.sql.SQLException
setBinaryStream()
.pstmt
- the prepared statementiColumn
- the column in the prepared statement to setobj
- the object to set (must implement Serializable)java.io.IOException
- if an i/o error occurredjava.sql.SQLException
- if a SQL related database error occurredPreparedStatement.setBinaryStream(int, java.io.InputStream, int)
public static java.lang.Object getSerializableObject(java.sql.ResultSet rs, java.lang.String sColumnName) throws java.io.IOException, java.lang.ClassNotFoundException, java.sql.SQLException
ResultSet
.rs
- the result set to get the object fromsColumnName
- the column to get fromjava.io.IOException
- if an i/o error occurredjava.lang.ClassNotFoundException
- if a class could not be foundjava.sql.SQLException
- if a SQL related database error occurredResultSet.getBinaryStream(String)
public static java.lang.Object getSerializableObject(java.sql.ResultSet rs, int iParameterIndex) throws java.io.IOException, java.lang.ClassNotFoundException, java.sql.SQLException
ResultSet
.rs
- the result set to get the object fromiParameterIndex
- the parameter index to get fromjava.io.IOException
- if an i/o error occurredjava.lang.ClassNotFoundException
- if a class could not be foundjava.sql.SQLException
- if a SQL related database error occurredResultSet.getBinaryStream(int)
public static java.io.InputStream getInputStreamToObject(java.lang.Object obj) throws java.io.IOException
InputStream
which reads the serialized data of an object.
Return null
if it could not be obtained. This implementation first
creates the serialized data in memory then returns an input stream to that data.obj
- the object to get an input stream tojava.io.IOException
- if an i/o error occurred, possibly because the object
is not serializablepublic static java.lang.Object getObjectFromInputStream(java.io.InputStream is) throws java.io.IOException, java.lang.ClassNotFoundException
InputStream
to its serialized data.is
- the input stream to get the object fromjava.io.IOException
- if an i/o error occurredjava.lang.ClassNotFoundException
- if the class obtained from the stream
could not be foundObjectInputStream
public static java.lang.String getQuotedColumn(java.lang.String column) throws com.compoze.ejb.persistence.PersistenceException
column
- a columncom.compoze.ejb.persistence.PersistenceException
- if the persistence could not be initializedpublic static com.compoze.ejb.persistence.database.IIdentifierFormat getIdentifierFormat() throws com.compoze.ejb.persistence.PersistenceException
columns
- a list of columnscom.compoze.ejb.persistence.PersistenceException
- if the persistence could not be initializedpublic static java.lang.String getQuotedColumn(java.lang.String[] columns) throws com.compoze.ejb.persistence.PersistenceException
columns
- a list of columnspublic static java.lang.String getQuotedColumn(java.lang.String column, com.compoze.ejb.persistence.database.IIdentifierFormat identifierFormat) throws com.compoze.ejb.persistence.PersistenceException
column
- a list of columndatabaseConfiguration
- the database configurationidentifierFormat
- the identifier formatpublic static java.lang.String getQuotedColumn(java.lang.String[] columns, com.compoze.ejb.persistence.database.IIdentifierFormat identifierFormat) throws com.compoze.ejb.persistence.PersistenceException
columns
- a list of columnsdatabaseConfiguration
- the database configurationidentifierFormat
- the identifier format
|
Compoze Software, Inc. | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |