BEA Systems, Inc.

com.beasys.commerce.util
Class JdbcHelper

java.lang.Object
  |
  +--com.beasys.commerce.util.JdbcHelper

public class JdbcHelper
extends java.lang.Object


Field Summary
static java.lang.Boolean supportsLikeEscapeClause
          Determine if the server configuration supports the LIKE ESCAPE clause.
 
Constructor Summary
JdbcHelper()
          Helper constructor comment.
 
Method Summary
static java.lang.Object deserialize(java.sql.ResultSet rs, int index)
          Convenience method for de-serializing an object from a JDBC source.
static double getDouble(java.sql.ResultSet rs, int index)
          Retrieve a double value from the ResultSet at the given index.
static double getDouble(java.sql.ResultSet rs, java.lang.String colName)
          Retrieve a double value from the ResultSet at the given column.
static float getFloat(java.sql.ResultSet rs, int index)
          Retrieve a float value from the ResultSet at the given index.
static float getFloat(java.sql.ResultSet rs, java.lang.String colName)
          Retrieve a float value from the ResultSet at the given column.
static int getInt(java.sql.ResultSet rs, int index)
          Retrieve an int value from the ResultSet at the given index.
static int getInt(java.sql.ResultSet rs, java.lang.String colName)
          Retrieve an int value from the ResultSet at the given column.
static long getLong(java.sql.ResultSet rs, int index)
          Retrieve a long value from the ResultSet at the given index.
static long getLong(java.sql.ResultSet rs, java.lang.String colName)
          Retrieve a long value from the ResultSet at the given column.
static void main(java.lang.String[] args)
           
static void serialize(java.sql.PreparedStatement ps, int index, java.io.Serializable obj)
          Convenience method for serializing an object to a JDBC stream.
static boolean supportsLikeEscapeClause(java.sql.Connection con)
          Determine if the given connection supports the LIKE ESCAPE clause.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

supportsLikeEscapeClause

public static final java.lang.Boolean supportsLikeEscapeClause
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.

Constructor Detail

JdbcHelper

public JdbcHelper()
Helper constructor comment.
Method Detail

serialize

public static void serialize(java.sql.PreparedStatement ps,
                             int index,
                             java.io.Serializable obj)
                      throws java.sql.SQLException,
                             java.io.IOException
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.

deserialize

public static java.lang.Object deserialize(java.sql.ResultSet rs,
                                           int index)
                                    throws java.sql.SQLException,
                                           java.io.IOException,
                                           java.io.StreamCorruptedException,
                                           java.lang.ClassNotFoundException
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.

supportsLikeEscapeClause

public static boolean supportsLikeEscapeClause(java.sql.Connection con)
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(java.sql.ResultSet rs,
                         int index)
                  throws java.sql.SQLException
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:
java.sql.SQLException - from retrieving the column.

getInt

public static int getInt(java.sql.ResultSet rs,
                         java.lang.String colName)
                  throws java.sql.SQLException
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:
java.sql.SQLException - from retrieving the column.

getLong

public static long getLong(java.sql.ResultSet rs,
                           int index)
                    throws java.sql.SQLException
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:
java.sql.SQLException - from retrieving the column.

getLong

public static long getLong(java.sql.ResultSet rs,
                           java.lang.String colName)
                    throws java.sql.SQLException
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:
java.sql.SQLException - from retrieving the column.

getFloat

public static float getFloat(java.sql.ResultSet rs,
                             int index)
                      throws java.sql.SQLException
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:
java.sql.SQLException - from retrieving the column.

getFloat

public static float getFloat(java.sql.ResultSet rs,
                             java.lang.String colName)
                      throws java.sql.SQLException
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:
java.sql.SQLException - from retrieving the column.

getDouble

public static double getDouble(java.sql.ResultSet rs,
                               int index)
                        throws java.sql.SQLException
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:
java.sql.SQLException - from retrieving the column.

getDouble

public static double getDouble(java.sql.ResultSet rs,
                               java.lang.String colName)
                        throws java.sql.SQLException
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:
java.sql.SQLException - from retrieving the column.

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception

BEA Systems, Inc.

Copyright © 2000 BEA Systems, Inc. All Rights Reserved