com.ibm.as400.access
Class SQLDataBase
- java.lang.Object
-
- com.ibm.as400.access.SQLDataBase
-
public abstract class SQLDataBase extends java.lang.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
Fields Modifier and Type Field and Description 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
Constructors Constructor and Description SQLDataBase(com.ibm.as400.access.SQLConversionSettings settings)
-
Method Summary
Methods Modifier and Type Method and Description abstract java.lang.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.java.sql.Array
getArray()
Converts (returns) the data to a java.sql.Array object.java.io.InputStream
getAsciiStream()
Converts the data to a stream of ASCII characters.java.math.BigDecimal
getBigDecimal(int scale)
Converts the data to a Java BigDecimal object.abstract java.io.InputStream
getBinaryStream()
Converts the data to a stream of uninterpreted bytes.abstract java.sql.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.java.io.Reader
getCharacterStream()
Converts the data to a java.io.Reader object.java.sql.Clob
getClob()
Converts the data to a java.sql.Clob object.abstract java.lang.String
getCreateParameters()
Returns the parameters used in creating the type.java.sql.Date
getDate(java.util.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 java.lang.String
getJavaClassName()
Returns the Java class name for ParameterMetaData.getParameterClassName().abstract java.lang.String
getLiteralPrefix()
Returns the prefix used to quote a literal.abstract java.lang.String
getLiteralSuffix()
Returns the suffix used to quote a literal.abstract java.lang.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.java.io.Reader
getNCharacterStream()
Converts the data to a java.io.Reader object.java.sql.NClob
getNClob()
Converts the data to a java.sql.NClob objectjava.lang.String
getNString()
Converts the data to String object.abstract java.lang.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 java.sql.RowId
getRowId()
Converts the data to a java.sql.RowId object.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 java.sql.SQLXML
getSQLXML()
Converts the data to a java.sql.SQLXML object.abstract java.lang.String
getString()
Converts the data to a Java String object.java.sql.Time
getTime(java.util.Calendar calendar)
Converts the data to a java.sql.Time object.java.sql.Timestamp
getTimestamp(java.util.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 java.lang.String
getTypeName()
Returns the name of the data type.java.io.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(java.lang.Object object, java.util.Calendar calendar, int scale)
Sets the contents of the data based on a Java object.void
updateSettings(com.ibm.as400.access.SQLConversionSettings settings)
-
-
-
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 java.lang.Object clone()
Returns a clone of the SQLData object. Use this sparingly so that we minimize the number of copies.- Overrides:
clone
in classjava.lang.Object
- Returns:
- The clone.
-
convertFromRawBytes
public abstract void convertFromRawBytes(byte[] rawBytes, int offset, com.ibm.as400.access.ConvTable converter) throws java.sql.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:
java.sql.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 java.sql.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:
java.sql.SQLException
-
set
public abstract void set(java.lang.Object object, java.util.Calendar calendar, int scale) throws java.sql.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:
java.sql.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 java.lang.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:
java.sql.SQLException
- If the index is invalid or an error occurs.
-
getJavaClassName
public abstract java.lang.String getJavaClassName()
Returns the Java class name for ParameterMetaData.getParameterClassName().- Returns:
- the Java class name.
-
getLiteralPrefix
public abstract java.lang.String getLiteralPrefix()
Returns the prefix used to quote a literal.- Returns:
- the prefix, or null if none.
-
getLiteralSuffix
public abstract java.lang.String getLiteralSuffix()
Returns the suffix used to quote a literal.- Returns:
- the suffix, or null if none.
-
getLocalName
public abstract java.lang.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 java.lang.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 java.io.InputStream getAsciiStream() throws java.sql.SQLException
Converts the data to a stream of ASCII characters.- Returns:
- the result of the conversion.
- Throws:
java.sql.SQLException
- If the conversion is not required or not possible.
-
getBigDecimal
public java.math.BigDecimal getBigDecimal(int scale) throws java.sql.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:
java.sql.SQLException
- If the conversion is not required or not possible.
-
getBinaryStream
public abstract java.io.InputStream getBinaryStream() throws java.sql.SQLException
Converts the data to a stream of uninterpreted bytes.- Returns:
- the result of the conversion.
- Throws:
java.sql.SQLException
- If the conversion is not required or not possible.
-
getBlob
public abstract java.sql.Blob getBlob() throws java.sql.SQLException
Converts the data to a java.sql.Blob object.- Returns:
- the result of the conversion.
- Throws:
java.sql.SQLException
- If the conversion is not required or not possible.
-
getBoolean
public boolean getBoolean() throws java.sql.SQLException
Converts the data to a Java boolean.- Returns:
- the result of the conversion.
- Throws:
java.sql.SQLException
- If the conversion is not required or not possible.
-
getByte
public byte getByte() throws java.sql.SQLException
Converts the data to a Java byte.- Returns:
- the result of the conversion.
- Throws:
java.sql.SQLException
- If the conversion is not required or not possible.
-
getBytes
public abstract byte[] getBytes() throws java.sql.SQLException
Converts the data to a Java byte array containing uninterpreted bytes.- Returns:
- the result of the conversion.
- Throws:
java.sql.SQLException
- If the conversion is not required or not possible.
-
getCharacterStream
public java.io.Reader getCharacterStream() throws java.sql.SQLException
Converts the data to a java.io.Reader object.- Returns:
- the result of the conversion.
- Throws:
java.sql.SQLException
- If the conversion is not required or not possible.
-
getClob
public java.sql.Clob getClob() throws java.sql.SQLException
Converts the data to a java.sql.Clob object.- Returns:
- the result of the conversion.
- Throws:
java.sql.SQLException
- If the conversion is not required or not possible.
-
getDate
public java.sql.Date getDate(java.util.Calendar calendar) throws java.sql.SQLException
Converts the data to a java.sql.Date object.- Parameters:
calendar
- The calendar.- Returns:
- the result of the conversion.
- Throws:
java.sql.SQLException
- If the conversion is not required or not possible.
-
getDouble
public double getDouble() throws java.sql.SQLException
Converts the data to a Java double.- Returns:
- the result of the conversion.
- Throws:
java.sql.SQLException
- If the conversion is not required or not possible.
-
getFloat
public float getFloat() throws java.sql.SQLException
Converts the data to a Java float.- Returns:
- the result of the conversion.
- Throws:
java.sql.SQLException
- If the conversion is not required or not possible.
-
getInt
public int getInt() throws java.sql.SQLException
Converts the data to a Java int.- Returns:
- the result of the conversion.
- Throws:
java.sql.SQLException
- If the conversion is not required or not possible.
-
getLong
public long getLong() throws java.sql.SQLException
Converts the data to a Java long.- Returns:
- the result of the conversion.
- Throws:
java.sql.SQLException
- If the conversion is not required or not possible.
-
getObject
public abstract java.lang.Object getObject() throws java.sql.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:
java.sql.SQLException
- If the conversion is not required or not possible.
-
getShort
public short getShort() throws java.sql.SQLException
Converts the data to a Java short.- Returns:
- the result of the conversion.
- Throws:
java.sql.SQLException
- If the conversion is not required or not possible.
-
getString
public abstract java.lang.String getString() throws java.sql.SQLException
Converts the data to a Java String object. This conversion must be provided by the implementation.- Returns:
- the result of the conversion.
- Throws:
java.sql.SQLException
-
getTime
public java.sql.Time getTime(java.util.Calendar calendar) throws java.sql.SQLException
Converts the data to a java.sql.Time object.- Parameters:
calendar
- The calendar.- Returns:
- the result of the conversion.
- Throws:
java.sql.SQLException
- If the conversion is not required or not possible.
-
getTimestamp
public java.sql.Timestamp getTimestamp(java.util.Calendar calendar) throws java.sql.SQLException
Converts the data to a java.sql.Timestamp object.- Parameters:
calendar
- The calendar.- Returns:
- the result of the conversion.
- Throws:
java.sql.SQLException
- If the conversion is not required or not possible.
-
getUnicodeStream
public java.io.InputStream getUnicodeStream() throws java.sql.SQLException
Converts the data to a stream of Unicdoe characters.- Returns:
- the result of the conversion.
- Throws:
java.sql.SQLException
- If the conversion is not required or not possible.
-
getNCharacterStream
public java.io.Reader getNCharacterStream() throws java.sql.SQLException
Converts the data to a java.io.Reader object.- Returns:
- the result of the conversion.
- Throws:
java.sql.SQLException
- If the conversion is not required or not possible.
-
getNClob
public java.sql.NClob getNClob() throws java.sql.SQLException
Converts the data to a java.sql.NClob object- Returns:
- the result of the conversion.
- Throws:
java.sql.SQLException
- If the conversion is not required or not possible.
-
getNString
public java.lang.String getNString() throws java.sql.SQLException
Converts the data to String object.- Returns:
- the result of the conversion.
- Throws:
java.sql.SQLException
- If the conversion is not required or not possible.
-
getSQLXML
public abstract java.sql.SQLXML getSQLXML() throws java.sql.SQLException
Converts the data to a java.sql.SQLXML object.- Returns:
- the result of the conversion.
- Throws:
java.sql.SQLException
- If the conversion is not required or not possible.
-
getRowId
public abstract java.sql.RowId getRowId() throws java.sql.SQLException
Converts the data to a java.sql.RowId object.- Returns:
- the result of the conversion.
- Throws:
java.sql.SQLException
- If the conversion is not required or not possible.
-
getArray
public java.sql.Array getArray() throws java.sql.SQLException
Converts (returns) the data to a java.sql.Array object.- Returns:
- the result of the conversion.
- Throws:
java.sql.SQLException
- If the conversion is not required or not possible.
-
updateSettings
public void updateSettings(com.ibm.as400.access.SQLConversionSettings settings)
-
-