org.h2.table

## Class TableLink

- java.lang.Object
- - org.h2.engine.DbObject
  - - org.h2.schema.SchemaObject
    - - org.h2.table.Table
      - - org.h2.table.TableLink

All Implemented Interfaces:
  HasSQL

    public class TableLink
    extends Table

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

### Field Summary

### Fields inherited from class org.h2.table.Table

`columns, compareMode, EXCLUSIVE_LOCK, isHidden, READ_LOCK, TYPE_CACHED, TYPE_MEMORY, WRITE_LOCK`

### Fields inherited from class org.h2.engine.DbObject

`AGGREGATE, comment, COMMENT, CONSTANT, CONSTRAINT, database, DOMAIN, FUNCTION_ALIAS, INDEX, RIGHT, ROLE, SCHEMA, SEQUENCE, SETTING, SYNONYM, TABLE_OR_VIEW, trace, TRIGGER, USER`

### Fields inherited from interface org.h2.util.HasSQL

`ADD_PLAN_INFORMATION, DEFAULT_SQL_FLAGS, NO_CASTS, QUOTE_ONLY_WHEN_REQUIRED, REPLACE_LOBS_FOR_TRACE, TRACE_SQL_FLAGS`

### Constructor Summary

Constructors
Constructor and Description
`TableLink(Schema schema, int id, java.lang.String name, java.lang.String driver, java.lang.String url, java.lang.String user, java.lang.String password, java.lang.String originalSchema, java.lang.String originalTable, boolean emitUpdates, boolean force)`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`Index` `addIndex(SessionLocal session, java.lang.String indexName, int indexId, IndexColumn[] cols, int uniqueColumnCount, IndexType indexType, boolean create, java.lang.String indexComment)` Create an index for this table
`void` `addRow(SessionLocal session, Row row)` Add a row to the table and all indexes.
`boolean` `canDrop()` Check if this table can be dropped.
`boolean` `canGetRowCount(SessionLocal session)` Check if the row count can be retrieved quickly.
`void` `checkSupportAlter()` Check if this table supports ALTER TABLE.
`void` `checkWritingAllowed()` Linked tables don't know if they are readonly.
`void` `close(SessionLocal session)` Close the table object and flush changes.
`void` `convertInsertRow(SessionLocal session, Row row, java.lang.Boolean overridingSystem)` Prepares the specified row for INSERT operation.
`void` `convertUpdateRow(SessionLocal session, Row row, boolean fromTrigger)` Prepares the specified row for UPDATE operation.
`java.sql.PreparedStatement` `execute(java.lang.String sql, java.util.ArrayList<Value> params, boolean reusePrepared, SessionLocal session)` Execute a SQL statement using the given parameters.
`boolean` `getAutocommit()` The autocommit mode
`java.lang.String` `getCreateSQL()` Construct the CREATE ...
`java.lang.String` `getDropSQL()` Construct a DROP ...
`int` `getFetchSize()` The number of rows to fetch default is 0
`java.lang.String` `getIdentifierQuoteString()` Returns the identifier quote string or space.
`java.util.ArrayList<Index>` `getIndexes()` Get all indexes for this table.
`long` `getMaxDataModificationId()` Get the last data modification id.
`java.lang.String` `getQualifiedTable()`
`long` `getRowCount(SessionLocal session)` Get the row count for this table.
`long` `getRowCountApproximation(SessionLocal session)` Get the approximated row count for this table.
`Index` `getScanIndex(SessionLocal session)` Get the scan index to iterate through all rows.
`TableType` `getTableType()` Get the table type name
`boolean` `isDeterministic()` Check if the table is deterministic.
`boolean` `isInsertable()` Returns whether this table is insertable.
`boolean` `isOracle()`
`void` `removeChildrenAndResources(SessionLocal session)` Delete all dependent children objects and resources of this object.
`void` `removeRow(SessionLocal session, Row row)` Remove a row from the table and all indexes.
`void` `reusePreparedStatement(java.sql.PreparedStatement prep, java.lang.String sql)` Add this prepared statement to the list of cached statements.
`void` `setAutoCommit(boolean mode)` Specify if the autocommit mode is activated or not
`void` `setFetchSize(int fetchSize)` Specify the number of rows fetched by the linked table command
`void` `setGlobalTemporary(boolean globalTemporary)`
`void` `setReadOnly(boolean readOnly)`
`long` `truncate(SessionLocal session)` Remove all rows from the table and indexes.
`void` `updateRows(Prepared prepared, SessionLocal session, LocalResult rows)` Update a list of rows in this table.
`static DbException` `wrapException(java.lang.String sql, java.lang.Exception ex)` Wrap a SQL exception that occurred while accessing a linked table.

### Methods inherited from class org.h2.table.Table

`addConstraint, addDependencies, addDependentMaterializedView, addDependentView, addSequence, addSynonym, addTrigger, canReference, canTruncate, checkDeadlock, compareValues, createRow, doesColumnExist, dropMultipleColumnsConstraintsAndIndexes, findColumn, findPrimaryKey, fire, fireAfterRow, fireBeforeRow, fireRow, getBestPlanItem, getCheckForeignKeyConstraints, getChildren, getColumn, getColumn, getColumn, getColumns, getCompareMode, getConstraints, getDependentMaterializedViews, getDependentViews, getDiskSpaceUsed, getIdentityColumn, getIndex, getIndexForColumn, getMainIndexColumn, getNullRow, getOnCommitDrop, getOnCommitTruncate, getPrimaryKey, getRow, getRowFactory, getRowIdColumn, getScanIndex, getSQLTableType, getTemplateRow, getTemplateSimpleRow, getTriggers, getType, hasSelectTrigger, isGlobalTemporary, isHidden, isLockedExclusively, isLockedExclusivelyBy, isPersistData, isPersistIndexes, isQueryComparable, isRowLockable, isTableExpression, isView, lock, lockRow, removeColumnExpressionsDependencies, removeConstraint, removeDependentMaterializedView, removeDependentView, removeIndex, removeIndexOrTransferOwnership, removeSequence, removeSynonym, removeTrigger, rename, renameColumn, setCheckForeignKeyConstraints, setColumns, setHidden, setOnCommitDrop, setOnCommitTruncate, setTableExpression, unlock, updateRow`

### Methods inherited from class org.h2.schema.SchemaObject

`getSchema, getSQL, getSQL`

### Methods inherited from class org.h2.engine.DbObject

`checkRename, getComment, getCreateSQLForCopy, getCreateSQLForMeta, getDatabase, getId, getModificationId, getName, invalidate, isTemporary, isValid, setComment, setModified, setObjectName, setTemporary, toString`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface org.h2.util.HasSQL

`getTraceSQL`

### Constructor Detail

#### TableLink

    public TableLink(Schema schema,
                     int id,
                     java.lang.String name,
                     java.lang.String driver,
                     java.lang.String url,
                     java.lang.String user,
                     java.lang.String password,
                     java.lang.String originalSchema,
                     java.lang.String originalTable,
                     boolean emitUpdates,
                     boolean force)

### Method Detail

#### getDropSQL

    public java.lang.String getDropSQL()

Description copied from class: `DbObject`
Construct a DROP ... SQL statement for this object.

Overrides:
  `getDropSQL` in class `DbObject`
Returns:
  the SQL statement

#### getCreateSQL

    public java.lang.String getCreateSQL()

Description copied from class: `DbObject`
Construct the CREATE ... SQL statement for this object.

Specified by:
  `getCreateSQL` in class `DbObject`
Returns:
  the SQL statement

#### addIndex

    public Index addIndex(SessionLocal session,
                          java.lang.String indexName,
                          int indexId,
                          IndexColumn[] cols,
                          int uniqueColumnCount,
                          IndexType indexType,
                          boolean create,
                          java.lang.String indexComment)

Description copied from class: `Table`
Create an index for this table

Specified by:
  `addIndex` in class `Table`
Parameters:
  `session` - the session
  `indexName` - the name of the index
  `indexId` - the id
  `cols` - the index columns
  `uniqueColumnCount` - the count of unique columns
  `indexType` - the index type
  `create` - whether this is a new index
  `indexComment` - the comment
Returns:
  the index

#### getScanIndex

    public Index getScanIndex(SessionLocal session)

Description copied from class: `Table`
Get the scan index to iterate through all rows.

Specified by:
  `getScanIndex` in class `Table`
Parameters:
  `session` - the session
Returns:
  the index

#### isInsertable

    public boolean isInsertable()

Description copied from class: `Table`
Returns whether this table is insertable.

Overrides:
  `isInsertable` in class `Table`
Returns:
  whether this table is insertable

#### removeRow

    public void removeRow(SessionLocal session,
                          Row row)

Description copied from class: `Table`
Remove a row from the table and all indexes.

Specified by:
  `removeRow` in class `Table`
Parameters:
  `session` - the session
  `row` - the row

#### addRow

    public void addRow(SessionLocal session,
                       Row row)

Description copied from class: `Table`
Add a row to the table and all indexes.

Specified by:
  `addRow` in class `Table`
Parameters:
  `session` - the session
  `row` - the row

#### close

    public void close(SessionLocal session)

Description copied from class: `Table`
Close the table object and flush changes.

Specified by:
  `close` in class `Table`
Parameters:
  `session` - the session

#### getRowCount

    public long getRowCount(SessionLocal session)

Description copied from class: `Table`
Get the row count for this table.

Specified by:
  `getRowCount` in class `Table`
Parameters:
  `session` - the session
Returns:
  the row count

#### wrapException

    public static DbException wrapException(java.lang.String sql,
                                            java.lang.Exception ex)

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

Parameters:
  `sql` - the SQL statement
  `ex` - the exception from the remote database
Returns:
  the wrapped exception

#### getQualifiedTable

    public java.lang.String getQualifiedTable()

#### execute

    public java.sql.PreparedStatement execute(java.lang.String sql,
                                              java.util.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` - the SQL statement
  `params` - the parameters or null
  `reusePrepared` - if the prepared statement can be re-used immediately
  `session` - the session
Returns:
  the prepared statement, or null if it is re-used

#### checkSupportAlter

    public void checkSupportAlter()

Description copied from class: `Table`
Check if this table supports ALTER TABLE.

Specified by:
  `checkSupportAlter` in class `Table`

#### truncate

    public long truncate(SessionLocal session)

Description copied from class: `Table`
Remove all rows from the table and indexes.

Specified by:
  `truncate` in class `Table`
Parameters:
  `session` - the session
Returns:
  number of removed rows, possibly including uncommitted rows

#### canGetRowCount

    public boolean canGetRowCount(SessionLocal session)

Description copied from class: `Table`
Check if the row count can be retrieved quickly.

Specified by:
  `canGetRowCount` in class `Table`
Parameters:
  `session` - the session
Returns:
  true if it can

#### canDrop

    public boolean canDrop()

Description copied from class: `Table`
Check if this table can be dropped.

Specified by:
  `canDrop` in class `Table`
Returns:
  true if it can

#### getTableType

    public TableType getTableType()

Description copied from class: `Table`
Get the table type name

Specified by:
  `getTableType` in class `Table`
Returns:
  the table type name

#### removeChildrenAndResources

    public void removeChildrenAndResources(SessionLocal session)

Description copied from class: `DbObject`
Delete all dependent children objects and resources of this object.

Overrides:
  `removeChildrenAndResources` in class `Table`
Parameters:
  `session` - the session

#### isOracle

    public boolean isOracle()

#### getIndexes

    public java.util.ArrayList<Index> getIndexes()

Description copied from class: `Table`
Get all indexes for this table.

Specified by:
  `getIndexes` in class `Table`
Returns:
  the list of indexes

#### getMaxDataModificationId

    public long getMaxDataModificationId()

Description copied from class: `Table`
Get the last data modification id.

Specified by:
  `getMaxDataModificationId` in class `Table`
Returns:
  the modification id

#### updateRows

    public void updateRows(Prepared prepared,
                           SessionLocal session,
                           LocalResult rows)

Description copied from class: `Table`
Update a list of rows in this table.

Overrides:
  `updateRows` in class `Table`
Parameters:
  `prepared` - the prepared statement
  `session` - the session
  `rows` - a list of row pairs of the form old row, new row, old row, new row,...

#### setGlobalTemporary

    public void setGlobalTemporary(boolean globalTemporary)

#### setReadOnly

    public void setReadOnly(boolean readOnly)

#### getRowCountApproximation

    public long getRowCountApproximation(SessionLocal session)

Description copied from class: `Table`
Get the approximated row count for this table.

Specified by:
  `getRowCountApproximation` in class `Table`
Parameters:
  `session` - the session
Returns:
  the approximated row count

#### reusePreparedStatement

    public void reusePreparedStatement(java.sql.PreparedStatement prep,
                                       java.lang.String sql)

Add this prepared statement to the list of cached statements.

Parameters:
  `prep` - the prepared statement
  `sql` - the SQL statement

#### isDeterministic

    public boolean isDeterministic()

Description copied from class: `Table`
Check if the table is deterministic.

Specified by:
  `isDeterministic` in class `Table`
Returns:
  true if it is

#### checkWritingAllowed

    public void checkWritingAllowed()

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

Overrides:
  `checkWritingAllowed` in class `Table`

#### convertInsertRow

    public void convertInsertRow(SessionLocal session,
                                 Row row,
                                 java.lang.Boolean overridingSystem)

Description copied from class: `Table`
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.

Overrides:
  `convertInsertRow` in class `Table`
Parameters:
  `session` - the session
  `row` - the row
  `overridingSystem` - `Boolean.TRUE` for `OVERRIDING SYSTEM VALUES`, `Boolean.FALSE` for `OVERRIDING USER VALUES`, `null` if override clause is not specified

#### convertUpdateRow

    public void convertUpdateRow(SessionLocal session,
                                 Row row,
                                 boolean fromTrigger)

Description copied from class: `Table`
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.

Overrides:
  `convertUpdateRow` in class `Table`
Parameters:
  `session` - the session
  `row` - the row
  `fromTrigger` - `true` if row was modified by INSERT or UPDATE trigger

#### setFetchSize

    public void setFetchSize(int fetchSize)

Specify the number of rows fetched by the linked table command

Parameters:
  `fetchSize` - to set

#### setAutoCommit

    public void setAutoCommit(boolean mode)

Specify if the autocommit mode is activated or not

Parameters:
  `mode` - to set

#### getAutocommit

    public boolean getAutocommit()

The autocommit mode

Returns:
  true if autocommit is on

#### getFetchSize

    public int getFetchSize()

The number of rows to fetch default is 0

Returns:
  number of rows to fetch

#### getIdentifierQuoteString

    public java.lang.String getIdentifierQuoteString()

Returns the identifier quote string or space.

Returns:
  the identifier quote string or space