com.beasys.commerce.util
Class JdbcHelper

java.lang.Object
  extended by com.beasys.commerce.util.JdbcHelper

Deprecated Use JdbcHelper

@Deprecated
public class JdbcHelper
extends Object


Field Summary
static boolean shouldUseClobsForReads
          Deprecated Controls whether we should use the Clob object or the ResultSet.getString() method to retrieve CLOB columns.
static boolean shouldUseClobsForWrites
          Deprecated Controls whether we should use the setCharacterStream() or the ResultSet.setString() method to set CLOB columns.
static Boolean supportsLikeEscapeClause
          Deprecated Determine if the server configuration supports the LIKE ESCAPE clause.
 
Constructor Summary
JdbcHelper()
          Deprecated Helper constructor comment.
 
Method Summary
static void close(Connection con)
          Deprecated  
static void close(ResultSet rs)
          Deprecated  
static void close(Statement stmt)
          Deprecated  
static Object deserialize(ResultSet rs, int index)
          Deprecated  
static String getClob(ResultSet rs, int index)
          Deprecated  
static Reader getClobReader(ResultSet rs, int index)
          Deprecated  
static Connection getConnection(DataSource src, int maxRetries)
          Deprecated  
static Connection getConnection(DataSource src, int maxRetries, long waitTime)
          Deprecated  
static double getDouble(ResultSet rs, int index)
          Deprecated  
static double getDouble(ResultSet rs, String colName)
          Deprecated  
static float getFloat(ResultSet rs, int index)
          Deprecated  
static float getFloat(ResultSet rs, String colName)
          Deprecated  
static int getInt(ResultSet rs, int index)
          Deprecated  
static int getInt(ResultSet rs, String colName)
          Deprecated  
static long getLong(ResultSet rs, int index)
          Deprecated  
static long getLong(ResultSet rs, String colName)
          Deprecated  
static boolean isNoResourceException(SQLException ex)
          Deprecated  
static void serialize(PreparedStatement ps, int index, Serializable obj)
          Deprecated  
static void setClob(PreparedStatement stmt, int index, Reader in, int length)
          Deprecated  
static void setClob(PreparedStatement stmt, int index, String str)
          Deprecated  
static boolean supportsLikeEscapeClause(Connection con)
          Deprecated  
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

supportsLikeEscapeClause

public static final Boolean supportsLikeEscapeClause
Deprecated 
Determine if the server configuration supports the LIKE ESCAPE clause.

This variable will initialized from the "commerce.jdbc.supportsLikeEscapeClause" property in weblogiccommerce.properties.

If this is null, then no configuration was specified and the JDBC connection should be queries. Otherwise, this will be true or false.


shouldUseClobsForReads

public static final boolean shouldUseClobsForReads
Deprecated 
Controls whether we should use the Clob object or the ResultSet.getString() method to retrieve CLOB columns.

This variable will initialized from the "commerce.jdbc.read.shouldUseClobs" property in weblogiccommerce.properties. Defaults to false


shouldUseClobsForWrites

public static final boolean shouldUseClobsForWrites
Deprecated 
Controls whether we should use the setCharacterStream() or the ResultSet.setString() method to set CLOB columns.

This variable will initialized from the "commerce.jdbc.write.shouldUseClobs" property in weblogiccommerce.properties. Defaults to false

Constructor Detail

JdbcHelper

public JdbcHelper()
Deprecated 
Helper constructor comment.

Method Detail

getConnection

public static Connection getConnection(DataSource src,
                                       int maxRetries,
                                       long waitTime)
                                throws SQLException
Deprecated 

Get a connection from a DataSource with retry and timeout logic.

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 maxRetries=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.

Parameters
src - the data source.
maxRetries - the maximum number of times to retry (less than 0 for infinite).
waitTime - the maximum number of milliseconds to try (less than 0 for infinite).
Returns
a connection from the data source on success.
Throws
SQLException - thrown on an error getting a connection.
See Also
isNoResourceException(java.sql.SQLException)

getConnection

public static Connection getConnection(DataSource src,
                                       int maxRetries)
                                throws SQLException
Deprecated 

Get a connection from a DataSource with retry logic.

Parameters
src - the data source.
maxRetries - the maximum number of times to retry (less than 0 for infinite).
Returns
a connection from the data source on success.
Throws
SQLException - thrown on an error getting a connection.

isNoResourceException

public static boolean isNoResourceException(SQLException ex)
Deprecated 

Tell if a SQLException is telling that no resources/connections are available right now.

When WLS doesn't have an available connection for a DataSource (either TX or non-TX), it will throw a SQLException with a message following this regular expression: "ResourceException.+[Nn]o.+available". That seems to the only way to tell if a connection wasn't availble from the underlying pool.


serialize

public static void serialize(PreparedStatement ps,
                             int index,
                             Serializable obj)
                      throws SQLException,
                             IOException
Deprecated 

Convenience method for serializing an object to a JDBC stream. Serializes the object and calls setBinaryStream() on the prepared statement. The data will be written out later when the statment is executed. Note: getBinaryStream() requires the size of the data bytes, so cannot use PipeInputStream, PipeOutputStream

Parameters
ps - PreparedStatement.
index - placeholder index of the serialized object.
obj - Object to be serialized.
Throws
SQLException
IOException

deserialize

public static Object deserialize(ResultSet rs,
                                 int index)
                          throws SQLException,
                                 IOException,
                                 StreamCorruptedException,
                                 ClassNotFoundException
Deprecated 

Convenience method for de-serializing an object from a JDBC source. Note: This method may be able to use PipedOutputStream and PipedInputStream.

Parameters
ps - Result Set.
index - table column index.
Throws
SQLException
IOException
StreamCorruptedException
ClassNotFoundException

supportsLikeEscapeClause

public static boolean supportsLikeEscapeClause(Connection con)
Deprecated 

Determine if the given connection supports the LIKE ESCAPE clause.

This first checks the supportsLikeEscapeClause varaible. It then checks with the Connection DatabaseMetaData.


getInt

public static int getInt(ResultSet rs,
                         int index)
                  throws SQLException
Deprecated 

Retrieve an int value from the ResultSet at the given index.

This will validate if the underlying column was null.

Parameters
rs - the result set.
index - the column index.
Returns
the column value (0 for null column).
Throws
SQLException - from retrieving the column.

getInt

public static int getInt(ResultSet rs,
                         String colName)
                  throws SQLException
Deprecated 

Retrieve an int value from the ResultSet at the given column.

This will validate if the underlying column was null.

Parameters
rs - the result set.
colName - the column name.
Returns
the column value (0 for null column).
Throws
SQLException - from retrieving the column.

getLong

public static long getLong(ResultSet rs,
                           int index)
                    throws SQLException
Deprecated 

Retrieve a long value from the ResultSet at the given index.

This will validate if the underlying column was null.

Parameters
rs - the result set.
index - the column index.
Returns
the column value (0 for null column).
Throws
SQLException - from retrieving the column.

getLong

public static long getLong(ResultSet rs,
                           String colName)
                    throws SQLException
Deprecated 

Retrieve a long value from the ResultSet at the given column.

This will validate if the underlying column was null.

Parameters
rs - the result set.
colName - the column name.
Returns
the column value (0 for null column).
Throws
SQLException - from retrieving the column.

getFloat

public static float getFloat(ResultSet rs,
                             int index)
                      throws SQLException
Deprecated 

Retrieve a float value from the ResultSet at the given index.

This will validate if the underlying column was null.

Parameters
rs - the result set.
index - the column index.
Returns
the column value (0 for null column).
Throws
SQLException - from retrieving the column.

getFloat

public static float getFloat(ResultSet rs,
                             String colName)
                      throws SQLException
Deprecated 

Retrieve a float value from the ResultSet at the given column.

This will validate if the underlying column was null.

Parameters
rs - the result set.
colName - the column name.
Returns
the column value (0 for null column).
Throws
SQLException - from retrieving the column.

getDouble

public static double getDouble(ResultSet rs,
                               int index)
                        throws SQLException
Deprecated 

Retrieve a double value from the ResultSet at the given index.

This will validate if the underlying column was null.

Parameters
rs - the result set.
index - the column index.
Returns
the column value (0 for null column).
Throws
SQLException - from retrieving the column.

getDouble

public static double getDouble(ResultSet rs,
                               String colName)
                        throws SQLException
Deprecated 

Retrieve a double value from the ResultSet at the given column.

This will validate if the underlying column was null.

Parameters
rs - the result set.
colName - the column name.
Returns
the column value (0 for null column).
Throws
SQLException - from retrieving the column.

getClob

public static String getClob(ResultSet rs,
                             int index)
                      throws SQLException
Deprecated 

Get the value of a CLOB column as a string.

This is controlled by the value of shouldUseClobsForReads.

Parameters
rs - the result set.
index - the column index in the result set.
Returns
the column as a string.
Throws
SQLException - thrown on an error.

getClobReader

public static Reader getClobReader(ResultSet rs,
                                   int index)
                            throws SQLException
Deprecated 

Get the value of a CLOB column as a reader.

This is controlled by the value of shouldUseClobsForReads.

Parameters
rs - the result set.
index - the column index in the result set.
Returns
the column as a reader, null on null.
Throws
SQLException - thrown on an error.

setClob

public static void setClob(PreparedStatement stmt,
                           int index,
                           String str)
                    throws SQLException
Deprecated 

Set the value of a CLOB column with a string.

This is controlled by the value of shouldUseClobsForWrites.

Parameters
stmt - the prepared statement.
index - the column index.
str - the CLOB string.
Throws
SQLException - thrown on an error.

setClob

public static void setClob(PreparedStatement stmt,
                           int index,
                           Reader in,
                           int length)
                    throws SQLException
Deprecated 

Set the value of a CLOB column with an input reader.

This is controlled by the value of shouldUseClobsForWrites.

Parameters
stmt - the prepared statement.
index - the column index.
in - the CLOB input reader.
Throws
SQLException - thrown on an error.

close

public static void close(Connection con)
Deprecated 

Close a connection, ignoring any errors.


close

public static void close(Statement stmt)
Deprecated 

Close a statement, ignoring any errors.


close

public static void close(ResultSet rs)
Deprecated 

Close a result set, ignoring any errors.



Copyright © 2000, 2009, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates.
Other names may be trademarks of their respective owners.