Top Description Fields Constructors Methods
org.apache.derby.vti

public abstract Class StringColumnVTI

extends VTITemplate
Class Inheritance
Known Direct Subclasses
org.apache.derby.vti.XmlVTI
Imports
java.io.ByteArrayInputStream, .InputStream, .UnsupportedEncodingException, java.math.BigDecimal, java.sql.Blob, .Clob, .Date, .SQLException, .Time, .Timestamp, java.text.DateFormat, .ParseException, org.apache.derby.shared.common.reference.SQLState, org.apache.derby.shared.common.error.StandardException, org.apache.derby.shared.common.util.ArrayUtil, org.apache.derby.iapi.types.HarmonySerialBlob, .HarmonySerialClob

This is an abstract table function which assumes that all columns are strings and which coerces the strings to reasonable values for various getXXX() methods. Subclasses must implement the following ResultSet methods:

and the following protected method introduced by this class:

Field Summary

Modifier and TypeField and Description
private String[]
private boolean

Constructor Summary

AccessConstructor and Description
public
StringColumnVTI(String[]
The names of the VTI's columns
columnNames
)

Build a StringColumnVTI with the given column names

Method Summary

Modifier and TypeMethod and Description
private void
checkNull(String columnValue)

Set the wasNull flag based on whether this column value turned out to be null.

public int
findColumn(String
the label for the column specified with the SQL AS clause. If the SQL AS clause was not specified, then the label is the name of the column
columnName
)

Overrides org.apache.derby.vti.VTITemplate.findColumn.

Implements java.sql.ResultSet.findColumn.

Maps the given ResultSet column label to its ResultSet column index.

public InputStream
getAsciiStream(int
the first column is 1, the second is 2, ...
columnIndex
)

Overrides org.apache.derby.vti.VTITemplate.getAsciiStream.

Implements java.sql.ResultSet.getAsciiStream.

Retrieves the value of the designated column in the current row of this ResultSet object as a stream of ASCII characters.

public BigDecimal
getBigDecimal(int
the first column is 1, the second is 2, ...
columnIndex
)

Overrides org.apache.derby.vti.VTITemplate.getBigDecimal.

Implements java.sql.ResultSet.getBigDecimal.

Retrieves the value of the designated column in the current row of this ResultSet object as a java.math.BigDecimal with full precision.

public InputStream
getBinaryStream(int
the first column is 1, the second is 2, ...
columnIndex
)

Overrides org.apache.derby.vti.VTITemplate.getBinaryStream.

Implements java.sql.ResultSet.getBinaryStream.

Retrieves the value of the designated column in the current row of this ResultSet object as a stream of uninterpreted bytes.

public Blob
getBlob(int
the first column is 1, the second is 2, ...
columnIndex
)

Overrides org.apache.derby.vti.VTITemplate.getBlob.

Implements java.sql.ResultSet.getBlob.

Retrieves the value of the designated column in the current row of this ResultSet object as a Blob object in the Java programming language.

public boolean
getBoolean(int
the first column is 1, the second is 2, ...
columnIndex
)

Overrides org.apache.derby.vti.VTITemplate.getBoolean.

Implements java.sql.ResultSet.getBoolean.

Retrieves the value of the designated column in the current row of this ResultSet object as a boolean in the Java programming language.

public byte
getByte(int
the first column is 1, the second is 2, ...
columnIndex
)

Overrides org.apache.derby.vti.VTITemplate.getByte.

Implements java.sql.ResultSet.getByte.

Retrieves the value of the designated column in the current row of this ResultSet object as a byte in the Java programming language.

public byte[]
getBytes(int
the first column is 1, the second is 2, ...
columnIndex
)

Overrides org.apache.derby.vti.VTITemplate.getBytes.

Implements java.sql.ResultSet.getBytes.

Retrieves the value of the designated column in the current row of this ResultSet object as a byte array in the Java programming language.

public Clob
getClob(int
the first column is 1, the second is 2, ...
columnIndex
)

Overrides org.apache.derby.vti.VTITemplate.getClob.

Implements java.sql.ResultSet.getClob.

Retrieves the value of the designated column in the current row of this ResultSet object as a Clob object in the Java programming language.

public int

Returns:

the number of columns in the VTI
getColumnCount
()

Get the number of columns.

public String

Returns:

the name of the corresponding column
getColumnName
(int
1-based position of column whose name is needed
columnNumber
)

Get name of a column (1-based indexing).

public Date
getDate(int
the first column is 1, the second is 2, ...
columnIndex
)

Overrides org.apache.derby.vti.VTITemplate.getDate.

Implements java.sql.ResultSet.getDate.

Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Date object in the Java programming language.

public double
getDouble(int
the first column is 1, the second is 2, ...
columnIndex
)

Overrides org.apache.derby.vti.VTITemplate.getDouble.

Implements java.sql.ResultSet.getDouble.

Retrieves the value of the designated column in the current row of this ResultSet object as a double in the Java programming language.

private InputStream
getEncodedStream(String columnValue, String encoding)

Turn a string into an appropriately encoded ByteArrayInputStream.

public float
getFloat(int
the first column is 1, the second is 2, ...
columnIndex
)

Overrides org.apache.derby.vti.VTITemplate.getFloat.

Implements java.sql.ResultSet.getFloat.

Retrieves the value of the designated column in the current row of this ResultSet object as a float in the Java programming language.

public int
getInt(int
the first column is 1, the second is 2, ...
columnIndex
)

Overrides org.apache.derby.vti.VTITemplate.getInt.

Implements java.sql.ResultSet.getInt.

Retrieves the value of the designated column in the current row of this ResultSet object as an int in the Java programming language.

public long
getLong(int
the first column is 1, the second is 2, ...
columnIndex
)

Overrides org.apache.derby.vti.VTITemplate.getLong.

Implements java.sql.ResultSet.getLong.

Retrieves the value of the designated column in the current row of this ResultSet object as a long in the Java programming language.

protected abstract String

Returns:

the string value of the corresponding column
getRawColumn
(int
The 1-based column index to lookup
columnNumber
)

Get the string value of the column in the current row identified by the 1-based columnNumber.

public short
getShort(int
the first column is 1, the second is 2, ...
columnIndex
)

Overrides org.apache.derby.vti.VTITemplate.getShort.

Implements java.sql.ResultSet.getShort.

Retrieves the value of the designated column in the current row of this ResultSet object as a short in the Java programming language.

public String
getString(int
the first column is 1, the second is 2, ...
columnIndex
)

Overrides org.apache.derby.vti.VTITemplate.getString.

Implements java.sql.ResultSet.getString.

Retrieves the value of the designated column in the current row of this ResultSet object as a String in the Java programming language.

public Time
getTime(int
the first column is 1, the second is 2, ...
columnIndex
)

Overrides org.apache.derby.vti.VTITemplate.getTime.

Implements java.sql.ResultSet.getTime.

Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Time object in the Java programming language.

public Timestamp
getTimestamp(int
the first column is 1, the second is 2, ...
columnIndex
)

Overrides org.apache.derby.vti.VTITemplate.getTimestamp.

Implements java.sql.ResultSet.getTimestamp.

Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Timestamp object in the Java programming language.

private SQLException
makeSQLException(String sqlstate, Object... args)

Construct a SQLException from a SQLState and args.

private long
parseDateTime(String columnValue)

Translate a date/time expression into the corresponding long number of milliseconds.

public void
setColumnNames(String[]
The names of the columns to be returned by this VTI
columnNames
)

Set the column names for this table function.

public boolean
wasNull()

Overrides org.apache.derby.vti.VTITemplate.wasNull.

Implements java.sql.ResultSet.wasNull.

Reports whether the last column read had a value of SQL NULL.

private SQLException
wrap(Throwable t)

Wrap an exception in a SQLException.

Inherited from org.apache.derby.vti.VTITemplate:
absoluteafterLastbeforeFirstcancelRowUpdatesclearWarningsdeleteRowfirstgetArraygetArraygetAsciiStreamgetBigDecimalgetBigDecimalgetBigDecimalgetBinaryStreamgetBlobgetBooleangetBytegetBytesgetCharacterStreamgetCharacterStreamgetClobgetConcurrencygetContextgetCursorNamegetDategetDategetDategetDoublegetFetchDirectiongetFetchSizegetFloatgetHoldabilitygetIntgetLonggetMetaDatagetNCharacterStreamgetNCharacterStreamgetNClobgetNClobgetNStringgetNStringgetObjectgetObjectgetObjectgetObjectgetObjectgetObjectgetRefgetRefgetReturnTableSignaturegetRowgetRowIdgetRowIdgetShortgetSQLXMLgetSQLXMLgetStatementgetStringgetTimegetTimegetTimegetTimestampgetTimestampgetTimestampgetTypegetUnicodeStreamgetUnicodeStreamgetURLgetURLgetWarningsinsertRowisAfterLastisBeforeFirstisClosedisFirstisLastisWrapperForlastmoveToCurrentRowmoveToInsertRownotImplementedpreviousrefreshRowrelativerowDeletedrowInsertedrowUpdatedsetContextsetFetchDirectionsetFetchSizeunwrapupdateArrayupdateArrayupdateAsciiStreamupdateAsciiStreamupdateAsciiStreamupdateAsciiStreamupdateAsciiStreamupdateAsciiStreamupdateBigDecimalupdateBigDecimalupdateBinaryStreamupdateBinaryStreamupdateBinaryStreamupdateBinaryStreamupdateBinaryStreamupdateBinaryStreamupdateBlobupdateBlobupdateBlobupdateBlobupdateBlobupdateBlobupdateBooleanupdateBooleanupdateByteupdateByteupdateBytesupdateBytesupdateCharacterStreamupdateCharacterStreamupdateCharacterStreamupdateCharacterStreamupdateCharacterStreamupdateCharacterStreamupdateClobupdateClobupdateClobupdateClobupdateClobupdateClobupdateDateupdateDateupdateDoubleupdateDoubleupdateFloatupdateFloatupdateIntupdateIntupdateLongupdateLongupdateNCharacterStreamupdateNCharacterStreamupdateNCharacterStreamupdateNCharacterStreamupdateNClobupdateNClobupdateNClobupdateNClobupdateNClobupdateNClobupdateNStringupdateNStringupdateNullupdateNullupdateObjectupdateObjectupdateObjectupdateObjectupdateRefupdateRefupdateRowupdateRowIdupdateRowIdupdateShortupdateShortupdateSQLXMLupdateSQLXMLupdateStringupdateStringupdateTimeupdateTimeupdateTimestampupdateTimestamp

Field Detail

_columnNamesback to summary
private String[] _columnNames
_lastColumnWasNullback to summary
private boolean _lastColumnWasNull

Constructor Detail

StringColumnVTIback to summary
public StringColumnVTI(String[] columnNames)

Build a StringColumnVTI with the given column names

Parameters
columnNames:String[]

The names of the VTI's columns

Method Detail

checkNullback to summary
private void checkNull(String columnValue)

Set the wasNull flag based on whether this column value turned out to be null.

findColumnback to summary
public int findColumn(String columnName) throws SQLException

Overrides org.apache.derby.vti.VTITemplate.findColumn.

Implements java.sql.ResultSet.findColumn.

Doc from java.sql.ResultSet.findColumn.

Maps the given ResultSet column label to its ResultSet column index.

Parameters
columnName:String

the label for the column specified with the SQL AS clause. If the SQL AS clause was not specified, then the label is the name of the column

Returns:int

the column index of the given column name

Exceptions
SQLException:
if the ResultSet object does not contain a column labeled columnLabel, a database access error occurs or this method is called on a closed result set
getAsciiStreamback to summary
public InputStream getAsciiStream(int columnIndex) throws SQLException

Overrides org.apache.derby.vti.VTITemplate.getAsciiStream.

Implements java.sql.ResultSet.getAsciiStream.

Doc from java.sql.ResultSet.getAsciiStream.

Retrieves the value of the designated column in the current row of this ResultSet object as a stream of ASCII characters. The value can then be read in chunks from the stream. This method is particularly suitable for retrieving large LONGVARCHAR values. The JDBC driver will do any necessary conversion from the database format into ASCII.

Note

All the data in the returned stream must be read prior to getting the value of any other column. The next call to a getter method implicitly closes the stream. Also, a stream may return 0 when the method InputStream.available is called whether there is data available or not.

Parameters
columnIndex:int

the first column is 1, the second is 2, ...

Returns:InputStream

a Java input stream that delivers the database column value as a stream of one-byte ASCII characters; if the value is SQL NULL, the value returned is null

Exceptions
SQLException:
if the columnIndex is not valid; if a database access error occurs or this method is called on a closed result set
getBigDecimalback to summary
public BigDecimal getBigDecimal(int columnIndex) throws SQLException

Overrides org.apache.derby.vti.VTITemplate.getBigDecimal.

Implements java.sql.ResultSet.getBigDecimal.

Doc from java.sql.ResultSet.getBigDecimal.

Retrieves the value of the designated column in the current row of this ResultSet object as a java.math.BigDecimal with full precision.

Parameters
columnIndex:int

the first column is 1, the second is 2, ...

Returns:BigDecimal

the column value (full precision); if the value is SQL NULL, the value returned is null in the Java programming language.

Exceptions
SQLException:
if the columnIndex is not valid; if a database access error occurs or this method is called on a closed result set
getBinaryStreamback to summary
public InputStream getBinaryStream(int columnIndex) throws SQLException

Overrides org.apache.derby.vti.VTITemplate.getBinaryStream.

Implements java.sql.ResultSet.getBinaryStream.

Doc from java.sql.ResultSet.getBinaryStream.

Retrieves the value of the designated column in the current row of this ResultSet object as a stream of uninterpreted bytes. The value can then be read in chunks from the stream. This method is particularly suitable for retrieving large LONGVARBINARY values.

Note

All the data in the returned stream must be read prior to getting the value of any other column. The next call to a getter method implicitly closes the stream. Also, a stream may return 0 when the method InputStream.available is called whether there is data available or not.

Parameters
columnIndex:int

the first column is 1, the second is 2, ...

Returns:InputStream

a Java input stream that delivers the database column value as a stream of uninterpreted bytes; if the value is SQL NULL, the value returned is null

Exceptions
SQLException:
if the columnIndex is not valid; if a database access error occurs or this method is called on a closed result set
getBlobback to summary
public Blob getBlob(int columnIndex) throws SQLException

Overrides org.apache.derby.vti.VTITemplate.getBlob.

Implements java.sql.ResultSet.getBlob.

Doc from java.sql.ResultSet.getBlob.

Retrieves the value of the designated column in the current row of this ResultSet object as a Blob object in the Java programming language.

Parameters
columnIndex:int

the first column is 1, the second is 2, ...

Returns:Blob

a Blob object representing the SQL BLOB value in the specified column

Exceptions
SQLException:
if the columnIndex is not valid; if a database access error occurs or this method is called on a closed result set
getBooleanback to summary
public boolean getBoolean(int columnIndex) throws SQLException

Overrides org.apache.derby.vti.VTITemplate.getBoolean.

Implements java.sql.ResultSet.getBoolean.

Doc from java.sql.ResultSet.getBoolean.

Retrieves the value of the designated column in the current row of this ResultSet object as a boolean in the Java programming language.

If the designated column has a datatype of CHAR or VARCHAR and contains a "0" or has a datatype of BIT, TINYINT, SMALLINT, INTEGER or BIGINT and contains a 0, a value of false is returned. If the designated column has a datatype of CHAR or VARCHAR and contains a "1" or has a datatype of BIT, TINYINT, SMALLINT, INTEGER or BIGINT and contains a 1, a value of true is returned.

Parameters
columnIndex:int

the first column is 1, the second is 2, ...

Returns:boolean

the column value; if the value is SQL NULL, the value returned is false

Exceptions
SQLException:
if the columnIndex is not valid; if a database access error occurs or this method is called on a closed result set
getByteback to summary
public byte getByte(int columnIndex) throws SQLException

Overrides org.apache.derby.vti.VTITemplate.getByte.

Implements java.sql.ResultSet.getByte.

Doc from java.sql.ResultSet.getByte.

Retrieves the value of the designated column in the current row of this ResultSet object as a byte in the Java programming language.

Parameters
columnIndex:int

the first column is 1, the second is 2, ...

Returns:byte

the column value; if the value is SQL NULL, the value returned is 0

Exceptions
SQLException:
if the columnIndex is not valid; if a database access error occurs or this method is called on a closed result set
getBytesback to summary
public byte[] getBytes(int columnIndex) throws SQLException

Overrides org.apache.derby.vti.VTITemplate.getBytes.

Implements java.sql.ResultSet.getBytes.

Doc from java.sql.ResultSet.getBytes.

Retrieves the value of the designated column in the current row of this ResultSet object as a byte array in the Java programming language. The bytes represent the raw values returned by the driver.

Parameters
columnIndex:int

the first column is 1, the second is 2, ...

Returns:byte[]

the column value; if the value is SQL NULL, the value returned is null

Exceptions
SQLException:
if the columnIndex is not valid; if a database access error occurs or this method is called on a closed result set
getClobback to summary
public Clob getClob(int columnIndex) throws SQLException

Overrides org.apache.derby.vti.VTITemplate.getClob.

Implements java.sql.ResultSet.getClob.

Doc from java.sql.ResultSet.getClob.

Retrieves the value of the designated column in the current row of this ResultSet object as a Clob object in the Java programming language.

Parameters
columnIndex:int

the first column is 1, the second is 2, ...

Returns:Clob

a Clob object representing the SQL CLOB value in the specified column

Exceptions
SQLException:
if the columnIndex is not valid; if a database access error occurs or this method is called on a closed result set
getColumnCountback to summary
public int getColumnCount()

Get the number of columns.

Returns:int

the number of columns in the VTI

getColumnNameback to summary
public String getColumnName(int columnNumber)

Get name of a column (1-based indexing).

Parameters
columnNumber:int

1-based position of column whose name is needed

Returns:String

the name of the corresponding column

getDateback to summary
public Date getDate(int columnIndex) throws SQLException

Overrides org.apache.derby.vti.VTITemplate.getDate.

Implements java.sql.ResultSet.getDate.

Doc from java.sql.ResultSet.getDate.

Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Date object in the Java programming language.

Parameters
columnIndex:int

the first column is 1, the second is 2, ...

Returns:Date

the column value; if the value is SQL NULL, the value returned is null

Exceptions
SQLException:
if the columnIndex is not valid; if a database access error occurs or this method is called on a closed result set
getDoubleback to summary
public double getDouble(int columnIndex) throws SQLException

Overrides org.apache.derby.vti.VTITemplate.getDouble.

Implements java.sql.ResultSet.getDouble.

Doc from java.sql.ResultSet.getDouble.

Retrieves the value of the designated column in the current row of this ResultSet object as a double in the Java programming language.

Parameters
columnIndex:int

the first column is 1, the second is 2, ...

Returns:double

the column value; if the value is SQL NULL, the value returned is 0

Exceptions
SQLException:
if the columnIndex is not valid; if a database access error occurs or this method is called on a closed result set
getEncodedStreamback to summary
private InputStream getEncodedStream(String columnValue, String encoding) throws SQLException

Turn a string into an appropriately encoded ByteArrayInputStream.

getFloatback to summary
public float getFloat(int columnIndex) throws SQLException

Overrides org.apache.derby.vti.VTITemplate.getFloat.

Implements java.sql.ResultSet.getFloat.

Doc from java.sql.ResultSet.getFloat.

Retrieves the value of the designated column in the current row of this ResultSet object as a float in the Java programming language.

Parameters
columnIndex:int

the first column is 1, the second is 2, ...

Returns:float

the column value; if the value is SQL NULL, the value returned is 0

Exceptions
SQLException:
if the columnIndex is not valid; if a database access error occurs or this method is called on a closed result set
getIntback to summary
public int getInt(int columnIndex) throws SQLException

Overrides org.apache.derby.vti.VTITemplate.getInt.

Implements java.sql.ResultSet.getInt.

Doc from java.sql.ResultSet.getInt.

Retrieves the value of the designated column in the current row of this ResultSet object as an int in the Java programming language.

Parameters
columnIndex:int

the first column is 1, the second is 2, ...

Returns:int

the column value; if the value is SQL NULL, the value returned is 0

Exceptions
SQLException:
if the columnIndex is not valid; if a database access error occurs or this method is called on a closed result set
getLongback to summary
public long getLong(int columnIndex) throws SQLException

Overrides org.apache.derby.vti.VTITemplate.getLong.

Implements java.sql.ResultSet.getLong.

Doc from java.sql.ResultSet.getLong.

Retrieves the value of the designated column in the current row of this ResultSet object as a long in the Java programming language.

Parameters
columnIndex:int

the first column is 1, the second is 2, ...

Returns:long

the column value; if the value is SQL NULL, the value returned is 0

Exceptions
SQLException:
if the columnIndex is not valid; if a database access error occurs or this method is called on a closed result set
getRawColumnback to summary
protected abstract String getRawColumn(int columnNumber) throws SQLException

Get the string value of the column in the current row identified by the 1-based columnNumber.

Parameters
columnNumber:int

The 1-based column index to lookup

Returns:String

the string value of the corresponding column

Exceptions
SQLException:
on error
getShortback to summary
public short getShort(int columnIndex) throws SQLException

Overrides org.apache.derby.vti.VTITemplate.getShort.

Implements java.sql.ResultSet.getShort.

Doc from java.sql.ResultSet.getShort.

Retrieves the value of the designated column in the current row of this ResultSet object as a short in the Java programming language.

Parameters
columnIndex:int

the first column is 1, the second is 2, ...

Returns:short

the column value; if the value is SQL NULL, the value returned is 0

Exceptions
SQLException:
if the columnIndex is not valid; if a database access error occurs or this method is called on a closed result set
getStringback to summary
public String getString(int columnIndex) throws SQLException

Overrides org.apache.derby.vti.VTITemplate.getString.

Implements java.sql.ResultSet.getString.

Doc from java.sql.ResultSet.getString.

Retrieves the value of the designated column in the current row of this ResultSet object as a String in the Java programming language.

Parameters
columnIndex:int

the first column is 1, the second is 2, ...

Returns:String

the column value; if the value is SQL NULL, the value returned is null

Exceptions
SQLException:
if the columnIndex is not valid; if a database access error occurs or this method is called on a closed result set
getTimeback to summary
public Time getTime(int columnIndex) throws SQLException

Overrides org.apache.derby.vti.VTITemplate.getTime.

Implements java.sql.ResultSet.getTime.

Doc from java.sql.ResultSet.getTime.

Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Time object in the Java programming language.

Parameters
columnIndex:int

the first column is 1, the second is 2, ...

Returns:Time

the column value; if the value is SQL NULL, the value returned is null

Exceptions
SQLException:
if the columnIndex is not valid; if a database access error occurs or this method is called on a closed result set
getTimestampback to summary
public Timestamp getTimestamp(int columnIndex) throws SQLException

Overrides org.apache.derby.vti.VTITemplate.getTimestamp.

Implements java.sql.ResultSet.getTimestamp.

Doc from java.sql.ResultSet.getTimestamp.

Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Timestamp object in the Java programming language.

Parameters
columnIndex:int

the first column is 1, the second is 2, ...

Returns:Timestamp

the column value; if the value is SQL NULL, the value returned is null

Exceptions
SQLException:
if the columnIndex is not valid; if a database access error occurs or this method is called on a closed result set
makeSQLExceptionback to summary
private SQLException makeSQLException(String sqlstate, Object... args)

Construct a SQLException from a SQLState and args.

parseDateTimeback to summary
private long parseDateTime(String columnValue) throws SQLException

Translate a date/time expression into the corresponding long number of milliseconds.

setColumnNamesback to summary
public void setColumnNames(String[] columnNames) throws SQLException

Set the column names for this table function. This is useful for AwareVTIs, which need to figure out their column names after analyzing their execution context. Throws an exception if the column names have already been set.

Parameters
columnNames:String[]

The names of the columns to be returned by this VTI

Exceptions
SQLException:
on error
wasNullback to summary
public boolean wasNull() throws SQLException

Overrides org.apache.derby.vti.VTITemplate.wasNull.

Implements java.sql.ResultSet.wasNull.

Doc from java.sql.ResultSet.wasNull.

Reports whether the last column read had a value of SQL NULL. Note that you must first call one of the getter methods on a column to try to read its value and then call the method wasNull to see if the value read was SQL NULL.

Returns:boolean

true if the last column value read was SQL NULL and false otherwise

Exceptions
SQLException:
if a database access error occurs or this method is called on a closed result set
wrapback to summary
private SQLException wrap(Throwable t)

Wrap an exception in a SQLException.