public class ExternalDatabaseTable extends java.lang.Object implements ExternalTable, TransactableTable
Example:
create external table emp (lname varchar(80), sid integer(6),
fname varchar(80), id integer(6) not null, dob timestamp(6))
organization (loadtype='remote' SERVER='myserver'
REMOTETABLE='mytablename' SCHEMA='myschema' WHERE='id > 1000');
Note : We have tested this for Oracle 8i/9i/10g , SQL Server, Sybase and DB2.
DatabaseLink
COLUMNS_ARE_CASE_SENSITIVE, DELIMITED_TABLE_TYPE, EXTERNAL_DB_TABLE_TYPE, FW_TABLE_TYPE, PROP_CATALOG, PROP_CREATE_IF_NOT_EXIST, PROP_DB, PROP_LOADTYPE, PROP_ORDERBY, PROP_REMOTETABLE, PROP_SCHEMA, PROP_VENDOR, PROP_WHERE, TAGGED_EBCDIC_TABLE_TYPE
REGULAR_TABLE_TYPE, SYSTEM_TABLE_TYPE
Constructor and Description |
---|
ExternalDatabaseTable(java.lang.String name,
Database db) |
Modifier and Type | Method and Description |
---|---|
void |
addColumn(Column col)
Add the given
Column to this table. |
void |
addConstraint(Constraint constraint) |
void |
addConstraint(Constraint constraint,
boolean checkExistingRows) |
void |
addIndex(Index index)
Add an index, associating it with a
Column , and adding it as a
org.axiondb.TableModificationListener to the table. |
void |
addRow(Row row)
Insert the given
Row . |
void |
addTableModificationListener(TableModificationListener listener)
Adds a listener to receive events on this table
|
void |
apply()
Apply this
committed transaction.. |
void |
applyDeletes(org.apache.commons.collections.primitives.IntCollection rowIds)
Remove the specified rows from this table and any associated indices.
|
void |
applyInserts(RowCollection rows)
Insert the given rows into this table and any associated indices.
|
void |
applyUpdates(RowCollection rows)
Update the given rows in this table and any associated indices.
|
protected void |
checkConstraints(RowEvent event) |
void |
checkpoint() |
void |
commit()
This transaction has been committed.
|
void |
deleteRow(Row row)
Delete the given
Row . |
void |
drop()
Drop this table from the database.
|
void |
freeRowId(int id)
Un-reserve a row id.
|
Column |
getColumn(int index)
Return the
Column corresponding to the given zero-based index . |
Column |
getColumn(java.lang.String name)
Return the
Column for the given name . |
int |
getColumnCount()
Return the number of
Column s I contain. |
java.util.List |
getColumnIdentifiers()
|
int |
getColumnIndex(java.lang.String name)
Return the zero-based index of the
Column with the given name . |
Constraint |
getConstraint(java.lang.String name) |
java.util.Iterator |
getConstraints() |
java.lang.String |
getDBLinkName() |
protected java.lang.String |
getDeleteSQL() |
RowIterator |
getIndexedRows(RowSource source,
Selectable node,
boolean readOnly) |
RowIterator |
getIndexedRows(Selectable node,
boolean readOnly) |
Index |
getIndexForColumn(Column column)
|
java.util.Iterator |
getIndices()
Obtain an
Iterator over my indices. |
protected java.lang.String |
getInsertSQL() |
RowIterator |
getMatchingRows(java.util.List selectables,
java.util.List values,
boolean readOnly)
Obtain an
iterator over my Row s where each
Selectable in the selectable list
evaluates to the corresponding value in the value
list . |
java.lang.String |
getName()
Get the name of this table.
|
int |
getNextRowId()
Reserve a row id.
|
Row |
getRow(int id) |
int |
getRowCount()
Return the number of
Row s I contain. |
protected RowIterator |
getRowIterator() |
RowIterator |
getRowIterator(boolean readOnly)
|
protected java.lang.String |
getSchemaWildcardForRemoteDB()
Gets appropriate string for use in indicating wildcard search for schemas.
|
protected java.lang.String |
getSelectSQL(java.lang.String where) |
Sequence |
getSequence() |
java.util.Iterator |
getTableModificationListeners() |
java.util.Properties |
getTableProperties()
Gets Organization Property.
|
java.lang.String |
getType()
Get the type of this table.
|
protected java.lang.String |
getUpdateSQL() |
boolean |
hasColumn(ColumnIdentifier id)
Indicate whether the
ColumnIdentifier references a column in this table |
boolean |
hasIndex(java.lang.String name) |
boolean |
isColumnIndexed(Column column)
|
boolean |
isPrimaryKeyConstraintExists(java.lang.String columnName)
check if primary constraint exists on a column
|
boolean |
isUniqueConstraintExists(java.lang.String columnName)
check if unique constraint exists on a column
|
boolean |
loadExternalTable(java.util.Properties props)
Loads external data using the given properties table - should be called only once by
the table factory.
|
RowDecorator |
makeRowDecorator() |
TransactableTable |
makeTransactableTable()
Create a
TransactableTable for this table. |
void |
migrate()
Migrate from older version to newer version for this table
|
void |
populateIndex(Index index)
Populate an
Index , adding my current rows to it. |
void |
remount() |
void |
remount(java.io.File dir,
boolean datafilesonly)
Notify this table that its disk-location has moved.
|
Constraint |
removeConstraint(java.lang.String name) |
void |
removeIndex(Index index)
Remove an index, both from the indices and as a TableModificationListener
|
void |
removeTableModificationListener(TableModificationListener listener)
Removes a listener so that it stops receiving events on this table
|
void |
rename(java.lang.String oldName,
java.lang.String newName) |
void |
rollback()
This transaction has been aborted.
|
void |
setDeferAllConstraints(boolean deferAll) |
void |
setSequence(Sequence seq) |
protected void |
setUp(DatabaseLink server) |
void |
shutdown()
The database is shutting down, shutdown this table also.
|
java.lang.String |
toString() |
void |
truncate()
Unconditionally delete all rows in this table.
|
void |
updateRow(Row oldrow,
Row newrow)
Update the given
Row . |
void |
updateRow(Row oldrow,
Row newrow,
java.util.List cols) |
public ExternalDatabaseTable(java.lang.String name, Database db)
public void addColumn(Column col) throws AxionException
Column
to this table. This implementation throws an
AxionException
if rows have already been added to the table.addColumn
in interface Table
AxionException
public void addConstraint(Constraint constraint) throws AxionException
addConstraint
in interface Table
AxionException
public void addConstraint(Constraint constraint, boolean checkExistingRows) throws AxionException
AxionException
public void addIndex(Index index) throws AxionException
Table
Column
, and adding it as a
org.axiondb.TableModificationListener
to the table.addIndex
in interface Table
AxionException
Table.addIndex(org.axiondb.Index)
,
Table.addTableModificationListener(org.axiondb.event.TableModificationListener)
,
Table.getIndexForColumn(org.axiondb.Column)
,
Table.isColumnIndexed(org.axiondb.Column)
,
Table.populateIndex(org.axiondb.Index)
public void addRow(Row row) throws AxionException
Table
Row
.addRow
in interface Table
AxionException
public void addTableModificationListener(TableModificationListener listener)
Table
addTableModificationListener
in interface Table
public void apply() throws AxionException
Transactable
committed
transaction..apply
in interface Transactable
AxionException
public void applyDeletes(org.apache.commons.collections.primitives.IntCollection rowIds) throws AxionException
Table
applyDeletes
in interface Table
AxionException
public void applyInserts(RowCollection rows)
Table
applyInserts
in interface Table
rows
- a collection of Rowspublic void applyUpdates(RowCollection rows)
Table
applyUpdates
in interface Table
public void checkpoint() throws AxionException
checkpoint
in interface Table
AxionException
public void commit() throws AxionException
Transactable
commit
in interface Transactable
AxionException
public void deleteRow(Row row) throws AxionException
Table
Row
.deleteRow
in interface Table
AxionException
public void drop() throws AxionException
Table
drop
in interface Table
AxionException
public void freeRowId(int id)
Table
public final Column getColumn(int index)
Table
Column
corresponding to the given zero-based index .public Column getColumn(java.lang.String name)
Table
Column
for the given name .public final int getColumnCount()
Table
Column
s I contain.getColumnCount
in interface RowSource
getColumnCount
in interface Table
public java.util.List getColumnIdentifiers()
Table
getColumnIdentifiers
in interface Table
public int getColumnIndex(java.lang.String name) throws AxionException
Table
Column
with the given name .getColumnIndex
in interface RowSource
getColumnIndex
in interface Table
AxionException
public final Constraint getConstraint(java.lang.String name)
getConstraint
in interface Table
public java.util.Iterator getConstraints()
getConstraints
in interface Table
public java.lang.String getDBLinkName()
public RowIterator getIndexedRows(RowSource source, Selectable node, boolean readOnly) throws AxionException
getIndexedRows
in interface Table
AxionException
public RowIterator getIndexedRows(Selectable node, boolean readOnly) throws AxionException
getIndexedRows
in interface Table
readOnly
- when true
, the caller does not expect to be able to
modify (i.e., call RowIterator.set(org.axiondb.Row)
or RowIterator.remove()
on)
the returned RowIterator
, the returned iterator may be
unmodifiable.AxionException
public Index getIndexForColumn(Column column)
Table
getIndexForColumn
in interface Table
Column
, or null
if no such
Index
existspublic java.util.Iterator getIndices()
Table
Iterator
over my indices.getIndices
in interface Table
public RowIterator getMatchingRows(java.util.List selectables, java.util.List values, boolean readOnly) throws AxionException
Table
iterator
over my Row
s where each
Selectable
in the selectable list
evaluates
to the corresponding value in the value
list
.
This is functionally similiar to executing a SELECT over this table where selectable[i] = value[i] for each value of i . The return RowIterator is not modifiable.
getMatchingRows
in interface Table
AxionException
public final java.lang.String getName()
Table
public int getNextRowId()
Table
getNextRowId
in interface Table
public Row getRow(int id) throws AxionException
getRow
in interface RowSource
AxionException
public int getRowCount()
Table
Row
s I contain.getRowCount
in interface Table
public RowIterator getRowIterator(boolean readOnly) throws AxionException
Table
getRowIterator
in interface Table
readOnly
- when true
, the caller does not expect to be able to
modify (i.e., call RowIterator.set(org.axiondb.Row)
or RowIterator.remove()
on)
the returned RowIterator
, the returned iterator may be
unmodifiable.AxionException
public final Sequence getSequence()
getSequence
in interface Table
public java.util.Iterator getTableModificationListeners()
getTableModificationListeners
in interface Table
public java.util.Properties getTableProperties()
ExternalTable
getTableProperties
in interface ExternalTable
public final java.lang.String getType()
Table
public boolean hasColumn(ColumnIdentifier id)
Table
ColumnIdentifier
references a column in this tablepublic boolean isColumnIndexed(Column column)
Table
isColumnIndexed
in interface Table
column
- Column
to checkIndex
for the given Column
public boolean isPrimaryKeyConstraintExists(java.lang.String columnName)
Table
isPrimaryKeyConstraintExists
in interface Table
public boolean isUniqueConstraintExists(java.lang.String columnName)
isUniqueConstraintExists
in interface Table
columnName
- name of the columnpublic boolean loadExternalTable(java.util.Properties props) throws AxionException
ExternalTable
loadExternalTable
in interface ExternalTable
props
- configuration properties for this external tableAxionException
public RowDecorator makeRowDecorator()
makeRowDecorator
in interface RowSource
makeRowDecorator
in interface Table
public TransactableTable makeTransactableTable()
Table
TransactableTable
for this table.makeTransactableTable
in interface Table
public void migrate() throws AxionException
Table
migrate
in interface Table
AxionException
public void populateIndex(Index index) throws AxionException
Table
populateIndex
in interface Table
AxionException
Table.addIndex(org.axiondb.Index)
public void remount() throws AxionException
remount
in interface ExternalTable
AxionException
public void remount(java.io.File dir, boolean datafilesonly) throws AxionException
Table
remount
in interface Table
AxionException
public Constraint removeConstraint(java.lang.String name)
removeConstraint
in interface Table
public void removeIndex(Index index) throws AxionException
Table
removeIndex
in interface Table
AxionException
public void removeTableModificationListener(TableModificationListener listener)
Table
removeTableModificationListener
in interface Table
public void rename(java.lang.String oldName, java.lang.String newName) throws AxionException
rename
in interface Table
AxionException
public void rollback() throws AxionException
Transactable
rollback
in interface Transactable
AxionException
public void setDeferAllConstraints(boolean deferAll)
setDeferAllConstraints
in interface Table
public void setSequence(Sequence seq) throws AxionException
setSequence
in interface Table
AxionException
public void shutdown() throws AxionException
Table
shutdown
in interface Table
AxionException
public java.lang.String toString()
toString
in class java.lang.Object
public void truncate() throws AxionException
Table
truncate
in interface Table
AxionException
public void updateRow(Row oldrow, Row newrow) throws AxionException
Table
Row
.updateRow
in interface Table
AxionException
public void updateRow(Row oldrow, Row newrow, java.util.List cols) throws AxionException
AxionException
protected void checkConstraints(RowEvent event) throws AxionException
AxionException
protected java.lang.String getDeleteSQL()
protected java.lang.String getInsertSQL()
protected RowIterator getRowIterator() throws AxionException
AxionException
protected java.lang.String getSchemaWildcardForRemoteDB()
protected java.lang.String getSelectSQL(java.lang.String where)
protected java.lang.String getUpdateSQL()
protected void setUp(DatabaseLink server) throws AxionException
AxionException