|
© 2005 BEA Systems, Inc. | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.bea.p13n.util.jdbc.GenericDatabase
Concrete implementation of the Database interface. This implementation is designed to be used with database drivers that support Statement.setCharacterStream() and Statement.setBinaryStream(). Drivers also need to support Clob.getCharacterStream() to write/read CLOBs and Blob.getBinaryStream() to write/read BLOBs.
The setClob, getClob, setBlob, and getBlob methods in this class should be overidden if a driver does not support the above methods when working with BLOBs and CLOBs.
Database
Constructor Summary | |
GenericDatabase(Connection connection)
|
Method Summary | |
boolean |
accept(Connection connection)
Check to see if the connection URL matches the format defined in "accept.driver.url.regex". |
void |
close()
Close the Connection associated with this Database. |
void |
close(InputStream is)
Closes an InputStream. |
void |
close(OutputStream os)
Closes an OutputStream. |
void |
close(PreparedStatement ps)
Closes a PreparedStatement. |
void |
close(Reader reader)
Closes a Reader. |
void |
close(ResultSet rs)
Close a result set, ignoring any errors. |
void |
close(ResultSet rs,
Statement stmt)
Close a statement and resultset, ignoring errors. |
void |
close(Statement stmt)
Closes a Statement. |
void |
close(Writer writer)
Closes a Writer. |
boolean |
commitConnection(Connection connection)
|
protected PreparedStatement |
createPreparedStatement(String key)
Creates a PreparedStatement based on queries found in ResourceBundle. |
void |
endBlob()
Commits Blob transaction. |
void |
endClob()
Commits Clob transaction. |
String |
getApplicationName()
Get the name of the current WebLogic J2EE application or return null if not running within a WebLogic J2EE context. |
byte[] |
getBlob(ResultSet rs,
int index)
Retrieve Blob value as a byte[] from a ResultSet. |
OutputStream |
getBlobLocator(Connection con,
String tableName,
String blobColumnName,
String whereClause)
Gets an OutputStream to the BlobLocator object. |
String |
getClob(ResultSet rs,
int index)
Get the value of a CLOB column as a string. |
Clob |
getClobLocator(Connection con,
String tableName,
String clobColumnName,
String whereClause)
|
String |
getClobTableName()
Used to retrieve the name of the table that stores Clobs. |
Connection |
getConnection()
Return Connection object of the current Database instance. |
String |
getEmptyBlobInitializer()
Returns an empty String since Pointbase doesn't use initializers. |
String |
getEmptyClobInitializer()
|
String |
getName()
The name of this GenericDatabase instance. |
protected String |
getProperty(String propertyName)
Used to retrieve a property in the ResourceBundle. |
protected void |
printSqlWarning(SQLWarning warning)
Prints the SQLWarning to System.err. |
String |
readFromClob(Clob clob)
Reads the contents of a Clob and returns as a String. |
String |
readFromClob(ResultSet resultSet,
int index)
Reads the contents of a Clob and returns as a String. |
boolean |
setClob(PreparedStatement stmt,
int index,
Clob clob,
String str)
If there is a delegate, this method uses JdbcHelperDelegate.writeClobData() If this is done, then the PreparedStatement does not need to be used and the return value, executeRequired, is false. |
void |
setClob(PreparedStatement stmt,
int index,
String str)
Set the value of a CLOB column with a string. |
void |
startBlob()
Starts the transaction to commit Blob. |
void |
startClob()
Starts the transaction to commit Clob. |
void |
writeToClob(Clob clob,
String data)
Writes the data from a String into a Clob. |
Reader |
writeToClob(PreparedStatement statement,
int index,
String data)
Writes the data from a String into a Clob using a PreparedStatement. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public GenericDatabase(Connection connection)
Method Detail |
public boolean accept(Connection connection)
accept
in interface Database
connection
- The Connection object that contains the URL.
public void close()
close
in interface Database
public void close(InputStream is)
close
in interface Database
is
- The InputStream.
IOException
- Thrown when closing InputStream.public void close(OutputStream os)
close
in interface Database
os
- The OutputStream to close.public void close(PreparedStatement ps)
close
in interface Database
ps
- The PreparedStatement object to be closed.public void close(Reader reader)
close
in interface Database
reader
- The Reader stream.public void close(ResultSet rs)
close
in interface Database
rs
- The ResultSet object to be closed.public void close(ResultSet rs, Statement stmt)
close
in interface Database
rs
- The ResultSet object to be closed.stmt
- The Statement object to be closed.public void close(Statement stmt)
close
in interface Database
stmt
- The Statement object to be closed.public void close(Writer writer)
close
in interface Database
writer
- The Writer stream.public boolean commitConnection(Connection connection) throws SQLException
commitConnection
in interface Database
SQLException
protected PreparedStatement createPreparedStatement(String key) throws SQLException
key
- The value in ResourceBundle which contains SQL Statement.
SQLException
public void endBlob() throws SQLException
endBlob
in interface Database
SQLException
- Thrown when committing Blob.public void endClob() throws SQLException
endClob
in interface Database
SQLException
- Thrown when committing Clob.public String getApplicationName()
getApplicationName
in interface Database
public byte[] getBlob(ResultSet rs, int index) throws SQLException
getBlob
in interface Database
rs
- The ResultSet containing the Blob.index
- The position of the Blob in the ResultSet.
SQLException
- on an errorpublic OutputStream getBlobLocator(Connection con, String tableName, String blobColumnName, String whereClause) throws SQLException
getBlobLocator
in interface Database
SQLException
- on an error.public String getClob(ResultSet rs, int index) throws SQLException
Database
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.
getClob
in interface Database
rs
- the result set.index
- the column index in the result set.
SQLException
- thrown on an error.public Clob getClobLocator(Connection con, String tableName, String clobColumnName, String whereClause) throws SQLException
getClobLocator
in interface Database
SQLException
public String getClobTableName()
public Connection getConnection()
getConnection
in interface Database
public String getEmptyBlobInitializer() throws SQLException
getEmptyBlobInitializer
in interface Database
SQLException
- on an error.public String getEmptyClobInitializer() throws SQLException
getEmptyClobInitializer
in interface Database
SQLException
public String getName()
getName
in interface Database
protected String getProperty(String propertyName)
propertyName
- The name of the property in the ResourceBundle.
IllegalStateException
- thrown if the property cannot be retrieved.protected void printSqlWarning(SQLWarning warning)
warning
- The SQLWarning from a Connection, Statement, or ResultSet.public String readFromClob(Clob clob) throws SQLException
readFromClob
in interface Database
clob
- The ResultSet object to be closed.
SQLException
- Thrown when error occurs while reading Clob.public String readFromClob(ResultSet resultSet, int index) throws SQLException
resultSet
- The ResultSet returned from a Statement
query.index
- The column index where the Clob can be found in
the ResultSet.
SQLException
- Thrown when error occurs when reading ResultSet.public boolean setClob(PreparedStatement stmt, int index, Clob clob, String str) throws SQLException
Database
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.
setClob
in interface Database
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)
SQLException
- thrown on an error.public void setClob(PreparedStatement stmt, int index, String str) throws SQLException
Database
setClob
in interface Database
stmt
- the prepared statement.index
- the column index.str
- the CLOB string.
SQLException
- thrown on an error.public void startBlob() throws SQLException
startBlob
in interface Database
SQLException
- Thrown when setting auto-commit to false.public void startClob() throws SQLException
startClob
in interface Database
SQLException
- Thrown when setting auto-commit to false.public void writeToClob(Clob clob, String data) throws SQLException
writeToClob
in interface Database
clob
- The target Clob object.data
- The data to be converted to a Clob in the form of a String.
SQLException
- Thrown because this is an unsupported operation.public Reader writeToClob(PreparedStatement statement, int index, String data) throws SQLException
index
- The index in the PreparedStatement that holds the Clob.data
- The data to be converted to be written as a Clob.
SQLException
- Thrown when retrieving character stream from statement.
|
© 2005 BEA Systems, Inc. | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |