|
© 2001 BEA Systems, Inc. | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.bea.p13n.util.jdbc.JdbcHelper
Method Summary | |
static void |
close(java.sql.Connection con)
Close a connection, ignoring any errors. |
static void |
close(java.sql.ResultSet rs)
Close a result set, ignoring any errors. |
static void |
close(java.sql.ResultSet rs,
java.sql.Statement stmt,
java.sql.Connection con)
Close a connection, statement and resultset, ignoring errors. |
static void |
close(java.sql.Statement stmt)
Close a statement, ignoring any errors. |
static void |
commitConnection(java.sql.Connection con)
Commits the java.sql.Connection that you have been using for CLOB operations. |
static java.lang.String |
getClob(java.sql.ResultSet rs,
int index)
Get the value of a CLOB column as a string. |
static java.sql.Clob |
getClobLocator(java.sql.Connection con,
java.lang.String tableName,
java.lang.String clobColumnName,
java.lang.String whereClause)
Retrieve the LOB locator for a CLOB. |
static java.sql.Connection |
getConnection(javax.sql.DataSource src,
int retries)
Get a connection from a DataSource with retry logic. |
static java.sql.Connection |
getConnection(javax.sql.DataSource src,
int retries,
long waitTime)
Get a connection from a DataSource with retry and timeout logic. |
static java.lang.String |
getEmptyClobInitializer()
Return the database specific keyword that must be used when inserting a row with an empty CLOB. |
static JdbcHelper |
getInstance()
|
static boolean |
setClob(java.sql.PreparedStatement stmt,
int index,
java.sql.Clob clob,
java.lang.String str)
If there is a delegate, this method uses JdbcHelperDelegate.writeClobData() |
static void |
setClob(java.sql.PreparedStatement stmt,
int index,
java.lang.String str)
Set the value of a CLOB column with a string. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Method Detail |
public static JdbcHelper getInstance()
public static java.lang.String getEmptyClobInitializer() throws java.sql.SQLException
For example, the method returns EMPTY_CLOB() when an Oracle delegate is used.
public static java.sql.Clob getClobLocator(java.sql.Connection con, java.lang.String tableName, java.lang.String clobColumnName, java.lang.String whereClause) throws java.sql.SQLException
This method only returns a single CLOB locator. If the WHERE clause results in mutiple rows, only the CLOB from the first row is returned.
If no JdbcHelperDelegate is specified in application-config.xml then this method will return null.
WARNING: if using a delegate to stream data to a CLOB, then you should use Connection.setAutoCommit(false) before calling this method. This will make the CLOB available across multiple SQL statements.
con
- the database connectiontableName
- the name of the database tableclobColumnName
- the name of the column holding the CLOBwhereClause
- the where clause (without WHERE keyword)public static java.sql.Connection getConnection(javax.sql.DataSource src, int retries, long waitTime) throws java.sql.SQLException
This will retry upto maxRetries. Additionally, it will only retry for waitTime number of milliseconds (as best as possible -- it might be longer, but will not be less).
This will always try at least once to get a connection. Use retries=0 for only a single attempt.
This works with both transactional and non-transaction DataSources tied to WLS connection pools. In WLS, transactional DataSources always internally wait 5 seconds for a new connection; non-transaction DataSources don't wait at all.
NOTE: The connection pool referenced by the given DataSource needs to be configured with the testConnOnReserve property set to true. This is necessary to ensure that in the event a SQLException is thrown, the cause of the exception is the unavailability of a pooled connection.
src
- the data source.retries
- the maximum number of times to retry (cannot
exceed maxRetries).waitTime
- the maximum number of milliseconds to try (cannot
exceed maxWaitTime).public static java.sql.Connection getConnection(javax.sql.DataSource src, int retries) throws java.sql.SQLException
src
- the data source.retries
- the maximum number of times to retry (cannot
exceed maxRetries).public static void close(java.sql.Connection con)
con
- The Connection object to be closed.public static void close(java.sql.Statement stmt)
stmt
- The Statement object to be closed.public static void close(java.sql.ResultSet rs)
rs
- The ResultSet object to be closed.public static void close(java.sql.ResultSet rs, java.sql.Statement stmt, java.sql.Connection con)
rs
- The ResultSet object to be closed.stmt
- The Statement object to be closed.con
- The Connection object to be closed.public static java.lang.String getClob(java.sql.ResultSet rs, int index) throws java.sql.SQLException
This method will only return the value of the CLOB in the current row of the ResultSet. This method does not increment the ResultSet cursor. You must use ResultSet.next() to increment the cursor before calling this method. This allows the method to be used to process multi-row ResultSets.
If no JdbcHelperDelegate is specified in the console (configured via JdbcHelperMBean) then this method will return a string obtained using the default method that was used before a delegate model was implemented for this class. That method uses Clob.getCharacterStream() to construct a BufferedReader that is read in with the readLine() method.
rs
- the result set.index
- the column index in the result set.public static void setClob(java.sql.PreparedStatement stmt, int index, java.lang.String str) throws java.sql.SQLException
stmt
- the prepared statement.index
- the column index.str
- the CLOB string.public static boolean setClob(java.sql.PreparedStatement stmt, int index, java.sql.Clob clob, java.lang.String str) throws java.sql.SQLException
stmt
- the prepared statement.index
- the column index.clob
- the CLOB locator (ignored if no delegate).str
- the String to be set in the CLOB (if delegate) or in the PreparedStatement (if no delegate)WARNING: if using a delegate to stream data to a CLOB, then you should have used Connection.setAutoCommit(false) before calling the CLOB locator method that provided the Clob you are using in this method call. This will make the CLOB available across multiple SQL statements.
public static void commitConnection(java.sql.Connection con) throws java.sql.SQLException
The delegate may implement this as a no-op method if it is illegal to do a Connection.commit() for the driver (e.g., jDriver for Oracle XA)
If there is no delegate, this method does a Connection.commit()
con
- the Connection
|
© 2001 BEA Systems, Inc. | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |