com.ibm.as400.access
Class SQLDataBase

java.lang.Object
  extended by com.ibm.as400.access.SQLDataBase

public abstract class SQLDataBase
extends Object

The SQLData interface represents native SQL data. A specific implementation of this interface will implement a specific type of SQL data.

This base class contains conversion methods usable by the sub classes.


Field Summary
static int ARRAY
           
static int BIGINT
           
static int BINARY
           
static int BLOB
           
static int BLOB_LOCATOR
           
static int CHAR
           
static int CHAR_FOR_BIT_DATA
           
static int CLOB
           
static int CLOB_LOCATOR
           
static int DATALINK
           
static int DATE
           
static int DBCLOB
           
static int DBCLOB_LOCATOR
           
static int DECFLOAT
           
static int DECIMAL
           
static int DECIMAL_USING_DOUBLE
           
static int DOUBLE
           
static int FLOAT
           
static int GRAPHIC
           
static int INTEGER
           
static int LONG_NVARCHAR
           
static int LONG_VARCHAR
           
static int LONG_VARCHAR_FOR_BIT_DATA
           
static int LONG_VARGRAPHIC
           
static short NATIVE_ARRAY
           
static int NCHAR
           
static int NCLOB
           
static int NCLOB_LOCATOR
           
static int NUMERIC
           
static int NUMERIC_USING_DOUBLE
           
static int NVARCHAR
           
protected  boolean outOfBounds_
           
static int REAL
           
static int ROWID
           
protected  com.ibm.as400.access.SQLConversionSettings settings_
           
static int SMALLINT
           
static int TIME
           
static int TIMESTAMP
           
protected  int truncated_
           
static int UNDEFINED
           
static int VARBINARY
           
static int VARCHAR
           
static int VARCHAR_FOR_BIT_DATA
           
static int VARGRAPHIC
           
static int XML_LOCATOR
           
 
Constructor Summary
SQLDataBase(com.ibm.as400.access.SQLConversionSettings settings)
           
 
Method Summary
abstract  Object clone()
          Returns a clone of the SQLData object.
abstract  void convertFromRawBytes(byte[] rawBytes, int offset, com.ibm.as400.access.ConvTable converter)
          Loads the contents of the data from raw bytes, as returned in a reply from the system.
abstract  void convertToRawBytes(byte[] rawBytes, int offset, com.ibm.as400.access.ConvTable ccsidConverter)
          Converts the contents of the data in raw bytes, as needed in a request to the system.
abstract  int getActualSize()
          Returns the actual size of this piece of data in bytes.
 Array getArray()
          Converts (returns) the data to a java.sql.Array object.
 InputStream getAsciiStream()
          Converts the data to a stream of ASCII characters.
 BigDecimal getBigDecimal(int scale)
          Converts the data to a Java BigDecimal object.
abstract  InputStream getBinaryStream()
          Converts the data to a stream of uninterpreted bytes.
abstract  Blob getBlob()
          Converts the data to a java.sql.Blob object.
 boolean getBoolean()
          Converts the data to a Java boolean.
 byte getByte()
          Converts the data to a Java byte.
abstract  byte[] getBytes()
          Converts the data to a Java byte array containing uninterpreted bytes.
 Reader getCharacterStream()
          Converts the data to a java.io.Reader object.
 Clob getClob()
          Converts the data to a java.sql.Clob object.
abstract  String getCreateParameters()
          Returns the parameters used in creating the type.
 Date getDate(Calendar calendar)
          Converts the data to a java.sql.Date object.
abstract  int getDisplaySize()
          Returns the display size.
 double getDouble()
          Converts the data to a Java double.
 float getFloat()
          Converts the data to a Java float.
 int getInt()
          Converts the data to a Java int.
abstract  String getJavaClassName()
          Returns the Java class name for ParameterMetaData.getParameterClassName().
abstract  String getLiteralPrefix()
          Returns the prefix used to quote a literal.
abstract  String getLiteralSuffix()
          Returns the suffix used to quote a literal.
abstract  String getLocalName()
          Returns the localized version of the name of the data type.
 long getLong()
          Converts the data to a Java long.
abstract  int getMaximumPrecision()
          Returns the maximum precision of the type.
abstract  int getMaximumScale()
          Returns the maximum scale of the type.
abstract  int getMinimumScale()
          Returns the minimum scale of the type.
abstract  int getNativeType()
          Returns the native IBM i identifier for the type.
 Reader getNCharacterStream()
          Converts the data to a java.io.Reader object.
 String getNString()
          Converts the data to String object.
abstract  Object getObject()
          Converts the data to a Java object.
abstract  boolean getOutOfBounds()
          Returns true if the last conversion of this piece of data was out of bounds of the range of the requested datatype.
abstract  int getPrecision()
          Returns the precision of the type.
abstract  int getRadix()
          Returns the radix for the type.
abstract  int getScale()
          Returns the scale of the type.
 short getShort()
          Converts the data to a Java short.
abstract  int getSQLType()
          Returns the SQL type constant for the implementing class.
abstract  String getString()
          Converts the data to a Java String object.
 Time getTime(Calendar calendar)
          Converts the data to a java.sql.Time object.
 Timestamp getTimestamp(Calendar calendar)
          Converts the data to a java.sql.Timestamp object.
abstract  int getTruncated()
          Returns the number of bytes truncated by the last conversion of this piece of data.
abstract  int getType()
          Returns the type constant associated with the type.
abstract  String getTypeName()
          Returns the name of the data type.
 InputStream getUnicodeStream()
          Converts the data to a stream of Unicdoe characters.
abstract  boolean isSigned()
          Indicates whether the type is signed.
abstract  boolean isText()
          Indicates whether the type is text.
abstract  void set(Object object, Calendar calendar, int scale)
          Sets the contents of the data based on a Java object.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

truncated_

protected int truncated_

outOfBounds_

protected boolean outOfBounds_

settings_

protected com.ibm.as400.access.SQLConversionSettings settings_

NATIVE_ARRAY

public static final short NATIVE_ARRAY
See Also:
Constant Field Values

UNDEFINED

public static final int UNDEFINED
See Also:
Constant Field Values

BIGINT

public static final int BIGINT
See Also:
Constant Field Values

BINARY

public static final int BINARY
See Also:
Constant Field Values

BLOB

public static final int BLOB
See Also:
Constant Field Values

BLOB_LOCATOR

public static final int BLOB_LOCATOR
See Also:
Constant Field Values

CHAR

public static final int CHAR
See Also:
Constant Field Values

CHAR_FOR_BIT_DATA

public static final int CHAR_FOR_BIT_DATA
See Also:
Constant Field Values

CLOB

public static final int CLOB
See Also:
Constant Field Values

CLOB_LOCATOR

public static final int CLOB_LOCATOR
See Also:
Constant Field Values

DATALINK

public static final int DATALINK
See Also:
Constant Field Values

DATE

public static final int DATE
See Also:
Constant Field Values

DBCLOB

public static final int DBCLOB
See Also:
Constant Field Values

DBCLOB_LOCATOR

public static final int DBCLOB_LOCATOR
See Also:
Constant Field Values

DECIMAL

public static final int DECIMAL
See Also:
Constant Field Values

DECIMAL_USING_DOUBLE

public static final int DECIMAL_USING_DOUBLE
See Also:
Constant Field Values

DOUBLE

public static final int DOUBLE
See Also:
Constant Field Values

FLOAT

public static final int FLOAT
See Also:
Constant Field Values

GRAPHIC

public static final int GRAPHIC
See Also:
Constant Field Values

INTEGER

public static final int INTEGER
See Also:
Constant Field Values

LONG_VARCHAR

public static final int LONG_VARCHAR
See Also:
Constant Field Values

LONG_VARCHAR_FOR_BIT_DATA

public static final int LONG_VARCHAR_FOR_BIT_DATA
See Also:
Constant Field Values

LONG_VARGRAPHIC

public static final int LONG_VARGRAPHIC
See Also:
Constant Field Values

NUMERIC

public static final int NUMERIC
See Also:
Constant Field Values

NUMERIC_USING_DOUBLE

public static final int NUMERIC_USING_DOUBLE
See Also:
Constant Field Values

REAL

public static final int REAL
See Also:
Constant Field Values

ROWID

public static final int ROWID
See Also:
Constant Field Values

SMALLINT

public static final int SMALLINT
See Also:
Constant Field Values

TIME

public static final int TIME
See Also:
Constant Field Values

TIMESTAMP

public static final int TIMESTAMP
See Also:
Constant Field Values

VARBINARY

public static final int VARBINARY
See Also:
Constant Field Values

VARCHAR

public static final int VARCHAR
See Also:
Constant Field Values

VARCHAR_FOR_BIT_DATA

public static final int VARCHAR_FOR_BIT_DATA
See Also:
Constant Field Values

VARGRAPHIC

public static final int VARGRAPHIC
See Also:
Constant Field Values

NCLOB

public static final int NCLOB
See Also:
Constant Field Values

NCLOB_LOCATOR

public static final int NCLOB_LOCATOR
See Also:
Constant Field Values

NCHAR

public static final int NCHAR
See Also:
Constant Field Values

NVARCHAR

public static final int NVARCHAR
See Also:
Constant Field Values

LONG_NVARCHAR

public static final int LONG_NVARCHAR
See Also:
Constant Field Values

DECFLOAT

public static final int DECFLOAT
See Also:
Constant Field Values

ARRAY

public static final int ARRAY
See Also:
Constant Field Values

XML_LOCATOR

public static final int XML_LOCATOR
See Also:
Constant Field Values
Constructor Detail

SQLDataBase

public SQLDataBase(com.ibm.as400.access.SQLConversionSettings settings)
Method Detail

clone

public abstract Object clone()
Returns a clone of the SQLData object. Use this sparingly so that we minimize the number of copies.

Overrides:
clone in class Object
Returns:
The clone.

convertFromRawBytes

public abstract void convertFromRawBytes(byte[] rawBytes,
                                         int offset,
                                         com.ibm.as400.access.ConvTable converter)
                                  throws SQLException
Loads the contents of the data from raw bytes, as returned in a reply from the system.

Parameters:
rawBytes - raw bytes from the system.
offset - offset.
converter - the converter.
Throws:
SQLException - If the raw bytes are not in the expected format.

convertToRawBytes

public abstract void convertToRawBytes(byte[] rawBytes,
                                       int offset,
                                       com.ibm.as400.access.ConvTable ccsidConverter)
                                throws SQLException
Converts the contents of the data in raw bytes, as needed in a request to the system.

Parameters:
rawBytes - the raw bytes for the system.
offset - the offset into the byte array.
ccsidConverter - the converter.
Throws:
SQLException

set

public abstract void set(Object object,
                         Calendar calendar,
                         int scale)
                  throws SQLException
Sets the contents of the data based on a Java object. This performs all conversions described in Table 6 of the JDBC specification.

Parameters:
object - a Java object.
calendar - The calendar.
scale - The scale.
Throws:
SQLException - If the Java object is not an appropriate type.

getSQLType

public abstract int getSQLType()
Returns the SQL type constant for the implementing class.

Returns:
the SQL type constant.

getCreateParameters

public abstract String getCreateParameters()
Returns the parameters used in creating the type.

Returns:
the parameters, separated by commas, or null if none.

getDisplaySize

public abstract int getDisplaySize()
Returns the display size. This is defined in Appendix D of the ODBC 2.0 Programmer's Reference.

Returns:
the display size (in characters).
Throws:
SQLException - If the index is invalid or an error occurs.

getJavaClassName

public abstract String getJavaClassName()
Returns the Java class name for ParameterMetaData.getParameterClassName().

Returns:
the Java class name.

getLiteralPrefix

public abstract String getLiteralPrefix()
Returns the prefix used to quote a literal.

Returns:
the prefix, or null if none.

getLiteralSuffix

public abstract String getLiteralSuffix()
Returns the suffix used to quote a literal.

Returns:
the suffix, or null if none.

getLocalName

public abstract String getLocalName()
Returns the localized version of the name of the data type.

Returns:
the name, or null.

getMaximumPrecision

public abstract int getMaximumPrecision()
Returns the maximum precision of the type. This is defined in Appendix D of the ODBC 2.0 Programmer's Reference.

Returns:
the maximum precision.

getMaximumScale

public abstract int getMaximumScale()
Returns the maximum scale of the type. This is defined in Appendix D of the ODBC 2.0 Programmer's Reference.

Returns:
the maximum scale.

getMinimumScale

public abstract int getMinimumScale()
Returns the minimum scale of the type. This is defined in Appendix D of the ODBC 2.0 Programmer's Reference.

Returns:
the minimum scale.

getNativeType

public abstract int getNativeType()
Returns the native IBM i identifier for the type.

Returns:
the native type.

getPrecision

public abstract int getPrecision()
Returns the precision of the type. This is defined in Appendix D of the ODBC 2.0 Programmer's Reference.

Returns:
the precision.

getRadix

public abstract int getRadix()
Returns the radix for the type.

Returns:
the radix.

getScale

public abstract int getScale()
Returns the scale of the type. This is defined in Appendix D of the ODBC 2.0 Programmer's Reference.

Returns:
the scale.

getType

public abstract int getType()
Returns the type constant associated with the type.

Returns:
SQL type code defined in java.sql.Types.

getTypeName

public abstract String getTypeName()
Returns the name of the data type.

Returns:
the name.

isSigned

public abstract boolean isSigned()
Indicates whether the type is signed.

Returns:
true or false

isText

public abstract boolean isText()
Indicates whether the type is text. This also indicates that the associated data needs to be converted.

Returns:
true or false

getActualSize

public abstract int getActualSize()
Returns the actual size of this piece of data in bytes.

Returns:
the actual size of this piece of data in bytes.

getTruncated

public abstract int getTruncated()
Returns the number of bytes truncated by the last conversion of this piece of data.

Returns:
the number of bytes truncated by the last conversion

getOutOfBounds

public abstract boolean getOutOfBounds()
Returns true if the last conversion of this piece of data was out of bounds of the range of the requested datatype. This will only happen when requesting conversion to a numeric type.


getAsciiStream

public InputStream getAsciiStream()
                           throws SQLException
Converts the data to a stream of ASCII characters.

Returns:
the result of the conversion.
Throws:
SQLException - If the conversion is not required or not possible.

getBigDecimal

public BigDecimal getBigDecimal(int scale)
                         throws SQLException
Converts the data to a Java BigDecimal object.

Parameters:
scale - scale, or -1 to use full scale.
Returns:
the result of the conversion.
Throws:
SQLException - If the conversion is not required or not possible.

getBinaryStream

public abstract InputStream getBinaryStream()
                                     throws SQLException
Converts the data to a stream of uninterpreted bytes.

Returns:
the result of the conversion.
Throws:
SQLException - If the conversion is not required or not possible.

getBlob

public abstract Blob getBlob()
                      throws SQLException
Converts the data to a java.sql.Blob object.

Returns:
the result of the conversion.
Throws:
SQLException - If the conversion is not required or not possible.

getBoolean

public boolean getBoolean()
                   throws SQLException
Converts the data to a Java boolean.

Returns:
the result of the conversion.
Throws:
SQLException - If the conversion is not required or not possible.

getByte

public byte getByte()
             throws SQLException
Converts the data to a Java byte.

Returns:
the result of the conversion.
Throws:
SQLException - If the conversion is not required or not possible.

getBytes

public abstract byte[] getBytes()
                         throws SQLException
Converts the data to a Java byte array containing uninterpreted bytes.

Returns:
the result of the conversion.
Throws:
SQLException - If the conversion is not required or not possible.

getCharacterStream

public Reader getCharacterStream()
                          throws SQLException
Converts the data to a java.io.Reader object.

Returns:
the result of the conversion.
Throws:
SQLException - If the conversion is not required or not possible.

getClob

public Clob getClob()
             throws SQLException
Converts the data to a java.sql.Clob object.

Returns:
the result of the conversion.
Throws:
SQLException - If the conversion is not required or not possible.

getDate

public Date getDate(Calendar calendar)
             throws SQLException
Converts the data to a java.sql.Date object.

Parameters:
calendar - The calendar.
Returns:
the result of the conversion.
Throws:
SQLException - If the conversion is not required or not possible.

getDouble

public double getDouble()
                 throws SQLException
Converts the data to a Java double.

Returns:
the result of the conversion.
Throws:
SQLException - If the conversion is not required or not possible.

getFloat

public float getFloat()
               throws SQLException
Converts the data to a Java float.

Returns:
the result of the conversion.
Throws:
SQLException - If the conversion is not required or not possible.

getInt

public int getInt()
           throws SQLException
Converts the data to a Java int.

Returns:
the result of the conversion.
Throws:
SQLException - If the conversion is not required or not possible.

getLong

public long getLong()
             throws SQLException
Converts the data to a Java long.

Returns:
the result of the conversion.
Throws:
SQLException - If the conversion is not required or not possible.

getObject

public abstract Object getObject()
                          throws SQLException
Converts the data to a Java object. The actual type of the Java object is dictated per section 8, table 2 ("Standard mapping from SQL types to Java types") of the JDBC 1.10 specification

Returns:
the result of the conversion.
Throws:
SQLException - If the conversion is not required or not possible.

getShort

public short getShort()
               throws SQLException
Converts the data to a Java short.

Returns:
the result of the conversion.
Throws:
SQLException - If the conversion is not required or not possible.

getString

public abstract String getString()
                          throws SQLException
Converts the data to a Java String object. This conversion must be provided by the implementation.

Returns:
the result of the conversion.
Throws:
SQLException

getTime

public Time getTime(Calendar calendar)
             throws SQLException
Converts the data to a java.sql.Time object.

Parameters:
calendar - The calendar.
Returns:
the result of the conversion.
Throws:
SQLException - If the conversion is not required or not possible.

getTimestamp

public Timestamp getTimestamp(Calendar calendar)
                       throws SQLException
Converts the data to a java.sql.Timestamp object.

Parameters:
calendar - The calendar.
Returns:
the result of the conversion.
Throws:
SQLException - If the conversion is not required or not possible.

getUnicodeStream

public InputStream getUnicodeStream()
                             throws SQLException
Converts the data to a stream of Unicdoe characters.

Returns:
the result of the conversion.
Throws:
SQLException - If the conversion is not required or not possible.

getNCharacterStream

public Reader getNCharacterStream()
                           throws SQLException
Converts the data to a java.io.Reader object.

Returns:
the result of the conversion.
Throws:
SQLException - If the conversion is not required or not possible.

getNString

public String getNString()
                  throws SQLException
Converts the data to String object.

Returns:
the result of the conversion.
Throws:
SQLException - If the conversion is not required or not possible.

getArray

public Array getArray()
               throws SQLException
Converts (returns) the data to a java.sql.Array object.

Returns:
the result of the conversion.
Throws:
SQLException - If the conversion is not required or not possible.