Top Description Fields Constructors Methods
org.h2.table

public Class TableLink

extends Table
Class Inheritance
Imports
java.sql.DatabaseMetaData, .PreparedStatement, .ResultSet, .ResultSetMetaData, .SQLException, .Statement, .Types, java.util.ArrayList, .HashMap, .List, .Objects, org.h2.api.ErrorCode, org.h2.command.Prepared, org.h2.engine.NullsDistinct, .SessionLocal, org.h2.index.Index, .IndexType, .LinkedIndex, org.h2.jdbc.JdbcConnection, .JdbcResultSet, org.h2.message.DbException, org.h2.result.LocalResult, .ResultInterface, .Row, org.h2.schema.Schema, org.h2.util.JdbcUtils, .StringUtils, .Utils, org.h2.value.DataType, .TypeInfo, .Value, .ValueDate, .ValueTime, .ValueTimestamp

A linked table contains connection information for a table accessible by JDBC. The table may be stored in a different database.

Field Summary

Modifier and TypeField and Description
private boolean
private TableLinkConnection
private DbException
private String
private final boolean
private int
private boolean
private String
private final ArrayList<Index>
private LinkedIndex
private static final int
private final String
private String
private String
private HashMap<String, PreparedStatement>
private String
private boolean
private static final long
private String
private String
Inherited from org.h2.table.Table:
columnscompareModeEXCLUSIVE_LOCKREAD_LOCKTYPE_CACHEDTYPE_MEMORYWRITE_LOCK

Constructor Summary

AccessConstructor and Description

Method Summary

Modifier and TypeMethod and Description
private void
addIndex(List<Column> list, int uniqueColumnCount, IndexType indexType)

public Index
addIndex(SessionLocal
the session
session
,
String
the name of the index
indexName
,
int
the id
indexId
,
IndexColumn[]
the index columns
cols
,
int
the count of unique columns
uniqueColumnCount
,
IndexType
the index type
indexType
,
boolean
whether this is a new index
create
,
String
the comment
indexComment
)

Implements abstract org.h2.table.Table.addIndex.

Create an index for this table

public void
addRow(SessionLocal
the session
session
,
Row
the row
row
)

Implements abstract org.h2.table.Table.addRow.

Add a row to the table and all indexes.

public boolean
canDrop()

Implements abstract org.h2.table.Table.canDrop.

Check if this table can be dropped.

public boolean
canGetRowCount(SessionLocal
the session
session
)

Implements abstract org.h2.table.Table.canGetRowCount.

Check if the row count can be retrieved quickly.

private void
public void
checkSupportAlter()

Implements abstract org.h2.table.Table.checkSupportAlter.

Check if this table supports ALTER TABLE.

public void
checkWritingAllowed()

Overrides org.h2.table.Table.checkWritingAllowed.

Linked tables don't know if they are readonly.

public void
close(SessionLocal
the session
session
)

Implements abstract org.h2.table.Table.close.

Close the table object and flush changes.

private void
public void
convertInsertRow(SessionLocal
the session
session
,
Row
the row
row
,
Boolean
Boolean#TRUE for OVERRIDING SYSTEM VALUES, Boolean#FALSE for OVERRIDING USER VALUES, null if override clause is not specified
overridingSystem
)

Overrides org.h2.table.Table.convertInsertRow.

Prepares the specified row for INSERT operation.

private static long
convertPrecision(int sqlType, long precision)

private void
convertRow(SessionLocal session, Row row)

private static int
convertScale(int sqlType, int scale)

public void
convertUpdateRow(SessionLocal
the session
session
,
Row
the row
row
,
boolean
true if row was modified by INSERT or UPDATE trigger
fromTrigger
)

Overrides org.h2.table.Table.convertUpdateRow.

Prepares the specified row for UPDATE operation.

public PreparedStatement

Returns:

the prepared statement, or null if it is re-used
execute
(String
the SQL statement
sql
,
ArrayList<Value>
the parameters or null
params
,
boolean
if the prepared statement can be re-used immediately
reusePrepared
,
SessionLocal
the session
session
)

Execute a SQL statement using the given parameters.

public boolean

Returns:

true if autocommit is on
getAutocommit
()

The autocommit mode

public String
getCreateSQL()

Implements abstract org.h2.engine.DbObject.getCreateSQL.

Construct the CREATE ...

public String
getDropSQL()

Overrides org.h2.engine.DbObject.getDropSQL.

Construct a DROP ...

public int

Returns:

number of rows to fetch
getFetchSize
()

The number of rows to fetch default is 0

public String

Returns:

the identifier quote string or space
getIdentifierQuoteString
()

Returns the identifier quote string or space.

public ArrayList<Index>
getIndexes()

Implements abstract org.h2.table.Table.getIndexes.

Get all indexes for this table.

public long
getMaxDataModificationId()

Implements abstract org.h2.table.Table.getMaxDataModificationId.

Get the last data modification id.

public String
public synchronized long
getRowCount(SessionLocal
the session
session
)

Implements abstract org.h2.table.Table.getRowCount.

Get the row count for this table.

public long
getRowCountApproximation(SessionLocal
the session
session
)

Implements abstract org.h2.table.Table.getRowCountApproximation.

Get the approximated row count for this table.

public Index
getScanIndex(SessionLocal
the session
session
)

Implements abstract org.h2.table.Table.getScanIndex.

Get the scan index to iterate through all rows.

public TableType
getTableType()

Implements abstract org.h2.table.Table.getTableType.

Get the table type name

public boolean
isDeterministic()

Implements abstract org.h2.table.Table.isDeterministic.

Check if the table is deterministic.

public boolean
isInsertable()

Overrides org.h2.table.Table.isInsertable.

Returns whether this table is insertable.

public boolean
private void
private void
readIndexes(ResultSet rs, HashMap<String, Column> columnMap, String pkName)

private void
private String
public void
removeChildrenAndResources(SessionLocal
the session
session
)

Overrides org.h2.table.Table.removeChildrenAndResources.

Delete all dependent children objects and resources of this object.

public void
removeRow(SessionLocal
the session
session
,
Row
the row
row
)

Implements abstract org.h2.table.Table.removeRow.

Remove a row from the table and all indexes.

public void
reusePreparedStatement(PreparedStatement
the prepared statement
prep
,
String
the SQL statement
sql
)

Add this prepared statement to the list of cached statements.

public void
setAutoCommit(boolean
to set
mode
)

Specify if the autocommit mode is activated or not

public void
setFetchSize(int
to set
fetchSize
)

Specify the number of rows fetched by the linked table command

public void
setGlobalTemporary(boolean globalTemporary)

public void
setReadOnly(boolean readOnly)

public long
truncate(SessionLocal
the session
session
)

Implements abstract org.h2.table.Table.truncate.

Remove all rows from the table and indexes.

public void
updateRows(Prepared
the prepared statement
prepared
,
SessionLocal
the session
session
,
LocalResult
a list of row pairs of the form old row, new row, old row, new row,...
rows
)

Overrides org.h2.table.Table.updateRows.

Update a list of rows in this table.

public static DbException

Returns:

the wrapped exception
wrapException
(String
the SQL statement
sql
,
Exception
the exception from the remote database
ex
)

Wrap a SQL exception that occurred while accessing a linked table.

Inherited from org.h2.table.Table:
addConstraintaddDependenciesaddDependentMaterializedViewaddDependentViewaddSequenceaddSynonymaddTriggercanReferencecanTruncatecheckDeadlockcompareValuescreateRowdoesColumnExistdropMultipleColumnsConstraintsAndIndexesfindColumnfindPrimaryKeyfirefireAfterRowfireBeforeRowfireRowgetBestPlanItemgetCheckForeignKeyConstraintsgetChildrengetColumngetColumngetColumngetColumnsgetCompareModegetConstraintsgetDependentMaterializedViewsgetDependentViewsgetDiskSpaceUsedgetIdentityColumngetIndexgetIndexForColumngetMainIndexColumngetNullRowgetOnCommitDropgetOnCommitTruncategetPrimaryKeygetRowgetRowFactorygetRowIdColumngetScanIndexgetSQLTableTypegetTemplateRowgetTemplateSimpleRowgetTriggersgetTypegetVisibleColumnshasSelectTriggerisGlobalTemporaryisLockedExclusivelyisLockedExclusivelyByisPersistDataisPersistIndexesisQueryComparableisRowLockableisViewlocklockRowremoveColumnExpressionsDependenciesremoveConstraintremoveDependentMaterializedViewremoveDependentViewremoveIndexremoveIndexOrTransferOwnershipremoveSequenceremoveSynonymremoveTriggerrenamerenameColumnsetCheckForeignKeyConstraintssetColumnssetOnCommitDropsetOnCommitTruncateunlockupdateRow

Field Detail

autocommitback to summary
private boolean autocommit
connback to summary
private TableLinkConnection conn
connectExceptionback to summary
private DbException connectException
driverback to summary
private String driver
emitUpdatesback to summary
private final boolean emitUpdates
fetchSizeback to summary
private int fetchSize
globalTemporaryback to summary
private boolean globalTemporary
identifierQuoteStringback to summary
private String identifierQuoteString
indexesback to summary
private final ArrayList<Index> indexes
linkedIndexback to summary
private LinkedIndex linkedIndex
MAX_RETRYback to summary
private static final int MAX_RETRY
originalSchemaback to summary
private final String originalSchema
originalTableback to summary
private String originalTable
passwordback to summary
private String password
preparedMapback to summary
private HashMap<String, PreparedStatement> preparedMap
qualifiedTableNameback to summary
private String qualifiedTableName
readOnlyback to summary
private boolean readOnly
ROW_COUNT_APPROXIMATIONback to summary
private static final long ROW_COUNT_APPROXIMATION
urlback to summary
private String url
userback to summary
private String user

Constructor Detail

Method Detail

addIndexback to summary
private void addIndex(List<Column> list, int uniqueColumnCount, IndexType indexType)
addIndexback to summary
public Index addIndex(SessionLocal session, String indexName, int indexId, IndexColumn[] cols, int uniqueColumnCount, IndexType indexType, boolean create, String indexComment)

Implements abstract org.h2.table.Table.addIndex.

Doc from org.h2.table.Table.addIndex.

Create an index for this table

Parameters
session:SessionLocal

the session

indexName:String

the name of the index

indexId:int

the id

cols:IndexColumn[]

the index columns

uniqueColumnCount:int

the count of unique columns

indexType:IndexType

the index type

create:boolean

whether this is a new index

indexComment:String

the comment

Returns:Index

the index

Annotations
@Override
addRowback to summary
public void addRow(SessionLocal session, Row row)

Implements abstract org.h2.table.Table.addRow.

Doc from org.h2.table.Table.addRow.

Add a row to the table and all indexes.

Parameters
session:SessionLocal

the session

row:Row

the row

Annotations
@Override
canDropback to summary
public boolean canDrop()

Implements abstract org.h2.table.Table.canDrop.

Doc from org.h2.table.Table.canDrop.

Check if this table can be dropped.

Returns:boolean

true if it can

Annotations
@Override
canGetRowCountback to summary
public boolean canGetRowCount(SessionLocal session)

Implements abstract org.h2.table.Table.canGetRowCount.

Doc from org.h2.table.Table.canGetRowCount.

Check if the row count can be retrieved quickly.

Parameters
session:SessionLocal

the session

Returns:boolean

true if it can

Annotations
@Override
checkReadOnlyback to summary
private void checkReadOnly()
checkSupportAlterback to summary
public void checkSupportAlter()

Implements abstract org.h2.table.Table.checkSupportAlter.

Doc from org.h2.table.Table.checkSupportAlter.

Check if this table supports ALTER TABLE.

Annotations
@Override
checkWritingAllowedback to summary
public void checkWritingAllowed()

Overrides org.h2.table.Table.checkWritingAllowed.

Linked tables don't know if they are readonly. This overwrites the default handling.

Annotations
@Override
closeback to summary
public void close(SessionLocal session)

Implements abstract org.h2.table.Table.close.

Doc from org.h2.table.Table.close.

Close the table object and flush changes.

Parameters
session:SessionLocal

the session

Annotations
@Override
connectback to summary
private void connect()
convertInsertRowback to summary
public void convertInsertRow(SessionLocal session, Row row, Boolean overridingSystem)

Overrides org.h2.table.Table.convertInsertRow.

Doc from org.h2.table.Table.convertInsertRow.

Prepares the specified row for INSERT operation. Identity, default, and generated values are evaluated, all values are converted to target data types and validated. Base value of identity column is updated when required by compatibility mode.

Parameters
session:SessionLocal

the session

row:Row

the row

overridingSystem:Boolean

Boolean#TRUE for OVERRIDING SYSTEM VALUES, Boolean#FALSE for OVERRIDING USER VALUES, null if override clause is not specified

Annotations
@Override
convertPrecisionback to summary
private static long convertPrecision(int sqlType, long precision)
convertRowback to summary
private void convertRow(SessionLocal session, Row row)
convertScaleback to summary
private static int convertScale(int sqlType, int scale)
convertUpdateRowback to summary
public void convertUpdateRow(SessionLocal session, Row row, boolean fromTrigger)

Overrides org.h2.table.Table.convertUpdateRow.

Doc from org.h2.table.Table.convertUpdateRow.

Prepares the specified row for UPDATE operation. Default and generated values are evaluated, all values are converted to target data types and validated. Base value of identity column is updated when required by compatibility mode.

Parameters
session:SessionLocal

the session

row:Row

the row

fromTrigger:boolean

true if row was modified by INSERT or UPDATE trigger

Annotations
@Override
executeback to summary
public PreparedStatement execute(String sql, ArrayList<Value> params, boolean reusePrepared, SessionLocal session)

Execute a SQL statement using the given parameters. Prepared statements are kept in a hash map to avoid re-creating them.

Parameters
sql:String

the SQL statement

params:ArrayList<Value>

the parameters or null

reusePrepared:boolean

if the prepared statement can be re-used immediately

session:SessionLocal

the session

Returns:PreparedStatement

the prepared statement, or null if it is re-used

getAutocommitback to summary
public boolean getAutocommit()

The autocommit mode

Returns:boolean

true if autocommit is on

getCreateSQLback to summary
public String getCreateSQL()

Implements abstract org.h2.engine.DbObject.getCreateSQL.

Doc from org.h2.engine.DbObject.getCreateSQL.

Construct the CREATE ... SQL statement for this object.

Returns:String

the SQL statement

Annotations
@Override
getDropSQLback to summary
public String getDropSQL()

Overrides org.h2.engine.DbObject.getDropSQL.

Doc from org.h2.engine.DbObject.getDropSQL.

Construct a DROP ... SQL statement for this object.

Returns:String

the SQL statement

Annotations
@Override
getFetchSizeback to summary
public int getFetchSize()

The number of rows to fetch default is 0

Returns:int

number of rows to fetch

getIdentifierQuoteStringback to summary
public String getIdentifierQuoteString()

Returns the identifier quote string or space.

Returns:String

the identifier quote string or space

getIndexesback to summary
public ArrayList<Index> getIndexes()

Implements abstract org.h2.table.Table.getIndexes.

Doc from org.h2.table.Table.getIndexes.

Get all indexes for this table.

Returns:ArrayList<Index>

the list of indexes

Annotations
@Override
getMaxDataModificationIdback to summary
public long getMaxDataModificationId()

Implements abstract org.h2.table.Table.getMaxDataModificationId.

Doc from org.h2.table.Table.getMaxDataModificationId.

Get the last data modification id.

Returns:long

the modification id

Annotations
@Override
getQualifiedTableback to summary
public String getQualifiedTable()
getRowCountback to summary
public synchronized long getRowCount(SessionLocal session)

Implements abstract org.h2.table.Table.getRowCount.

Doc from org.h2.table.Table.getRowCount.

Get the row count for this table.

Parameters
session:SessionLocal

the session

Returns:long

the row count

Annotations
@Override
getRowCountApproximationback to summary
public long getRowCountApproximation(SessionLocal session)

Implements abstract org.h2.table.Table.getRowCountApproximation.

Doc from org.h2.table.Table.getRowCountApproximation.

Get the approximated row count for this table.

Parameters
session:SessionLocal

the session

Returns:long

the approximated row count

Annotations
@Override
getScanIndexback to summary
public Index getScanIndex(SessionLocal session)

Implements abstract org.h2.table.Table.getScanIndex.

Doc from org.h2.table.Table.getScanIndex.

Get the scan index to iterate through all rows.

Parameters
session:SessionLocal

the session

Returns:Index

the index

Annotations
@Override
getTableTypeback to summary
public TableType getTableType()

Implements abstract org.h2.table.Table.getTableType.

Doc from org.h2.table.Table.getTableType.

Get the table type name

Returns:TableType

the table type name

Annotations
@Override
isDeterministicback to summary
public boolean isDeterministic()

Implements abstract org.h2.table.Table.isDeterministic.

Doc from org.h2.table.Table.isDeterministic.

Check if the table is deterministic.

Returns:boolean

true if it is

Annotations
@Override
isInsertableback to summary
public boolean isInsertable()

Overrides org.h2.table.Table.isInsertable.

Doc from org.h2.table.Table.isInsertable.

Returns whether this table is insertable.

Returns:boolean

whether this table is insertable

Annotations
@Override
isOracleback to summary
public boolean isOracle()
readIndexesback to summary
private void readIndexes(DatabaseMetaData meta, HashMap<String, Column> columnMap)
readIndexesback to summary
private void readIndexes(ResultSet rs, HashMap<String, Column> columnMap, String pkName) throws SQLException
readMetaDataback to summary
private void readMetaData() throws SQLException
readPrimaryKeyback to summary
private String readPrimaryKey(ResultSet rs, HashMap<String, Column> columnMap) throws SQLException
removeChildrenAndResourcesback to summary
public void removeChildrenAndResources(SessionLocal session)

Overrides org.h2.table.Table.removeChildrenAndResources.

Doc from org.h2.engine.DbObject.removeChildrenAndResources.

Delete all dependent children objects and resources of this object.

Parameters
session:SessionLocal

the session

Annotations
@Override
removeRowback to summary
public void removeRow(SessionLocal session, Row row)

Implements abstract org.h2.table.Table.removeRow.

Doc from org.h2.table.Table.removeRow.

Remove a row from the table and all indexes.

Parameters
session:SessionLocal

the session

row:Row

the row

Annotations
@Override
reusePreparedStatementback to summary
public void reusePreparedStatement(PreparedStatement prep, String sql)

Add this prepared statement to the list of cached statements.

Parameters
prep:PreparedStatement

the prepared statement

sql:String

the SQL statement

setAutoCommitback to summary
public void setAutoCommit(boolean mode)

Specify if the autocommit mode is activated or not

Parameters
mode:boolean

to set

setFetchSizeback to summary
public void setFetchSize(int fetchSize)

Specify the number of rows fetched by the linked table command

Parameters
fetchSize:int

to set

setGlobalTemporaryback to summary
public void setGlobalTemporary(boolean globalTemporary)
setReadOnlyback to summary
public void setReadOnly(boolean readOnly)
truncateback to summary
public long truncate(SessionLocal session)

Implements abstract org.h2.table.Table.truncate.

Doc from org.h2.table.Table.truncate.

Remove all rows from the table and indexes.

Parameters
session:SessionLocal

the session

Returns:long

number of removed rows, possibly including uncommitted rows

Annotations
@Override
updateRowsback to summary
public void updateRows(Prepared prepared, SessionLocal session, LocalResult rows)

Overrides org.h2.table.Table.updateRows.

Doc from org.h2.table.Table.updateRows.

Update a list of rows in this table.

Parameters
prepared:Prepared

the prepared statement

session:SessionLocal

the session

rows:LocalResult

a list of row pairs of the form old row, new row, old row, new row,...

Annotations
@Override
wrapExceptionback to summary
public static DbException wrapException(String sql, Exception ex)

Wrap a SQL exception that occurred while accessing a linked table.

Parameters
sql:String

the SQL statement

ex:Exception

the exception from the remote database

Returns:DbException

the wrapped exception