: Class Table

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.mortbay.JDBC
Class Table

    java.lang.Object
      |
      +--com.mortbay.JDBC.ColumnGroup
            |
            +--com.mortbay.JDBC.Table

Direct Known Subclasses:
  MultiTestTable, RelationalTable

public class Table
extends ColumnGroup

JDBC Table wrapper

The Table class holds Meta data about a JDBC table. It is used in preference to JDBC metadata as:

- JDBC MetaData is not always implemented
- It can be used to create tables and indexes from within a program
- Some degree of additional DB portability is obtained

Version:
  $Id: Table.java,v 2.3 1999/09/22 15:08:40 gregw Exp $
Author:
  Greg Wilkins
See Also:
  `Database`

Field Summary
`ColumnGroup` | `otherCols`
`ColumnGroup` | `otherKeys`
`Key` | `primaryKey`

Fields inherited from class com.mortbay.JDBC.ColumnGroup
`columns`

Constructor Summary
`Table(java.lang.String name, Column[] columns, Database database)` Table constructor

Method Summary
`java.lang.String` | `create()`
`Database` | `database()`
`void` | `database(Database db)` Set the database used by this table.
`void` | `deleteRow(java.lang.Object primaryValues)` Delete a row from the table singular primary key
`void` | `deleteRows(ColumnGroup columns, java.lang.Object[] values)` Delete a row from the table by column group values
`void` | `deleteRows(java.lang.Object[] primaryValues)` Delete a row from the table by primary key values
`void` | `deleteRows(java.lang.String whereClause)` Delete a row from the table by arbitrary WHERE clause
`java.lang.String` | `drop()`
`DbAdaptor` | `getAdaptor()`
`Database` | `getDatabase()`
`Row` | `getRow(java.lang.Object primaryValue)` Get a row from the table if it has a single primary key Create it if it does not exist.
`Row` | `getRow(java.lang.Object[] primaryValues)` Get a row from the table.
`RowEnumeration` | `getRows(ColumnGroup columns, java.lang.Object[] values)` Get a rows from the table by non primary key
`RowEnumeration` | `getRows(java.lang.String whereClause)` Get a rows from the table by arbitrary where clause
`boolean` | `hasPrimary()` Does this table have a primary key
`Row` | `newRow()` Create a new row in the table
`java.lang.String` | `toString()` Create table description

Methods inherited from class com.mortbay.JDBC.ColumnGroup
`column, getName, index, main, toString, toString, toValuesString`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### primaryKey

    public Key primaryKey

### otherKeys

    public ColumnGroup otherKeys

### otherCols

    public ColumnGroup otherCols

Constructor Detail

### Table

    public Table(java.lang.String name,
                 Column[] columns,
                 Database database)

  Table constructor
  Parameters:
    `name` - The name of the table
    `columns` - Array of column descriptors
    `database` - The database to use.

Method Detail

### getDatabase

    public Database getDatabase()

  Returns:
    Database for table

### getAdaptor

    public DbAdaptor getAdaptor()

  Returns:
    DbAdaptor for table

### hasPrimary

    public boolean hasPrimary()

  Does this table have a primary key

### newRow

    public Row newRow()

  Create a new row in the table

### getRow

    public Row getRow(java.lang.Object primaryValue)
               throws java.sql.SQLException

  Get a row from the table if it has a single primary key Create it if it does not exist.

### getRow

    public Row getRow(java.lang.Object[] primaryValues)
               throws java.sql.SQLException

  Get a row from the table.

### getRows

    public RowEnumeration getRows(ColumnGroup columns,
                                  java.lang.Object[] values)
                           throws java.sql.SQLException

  Get a rows from the table by non primary key

### getRows

    public RowEnumeration getRows(java.lang.String whereClause)
                           throws java.sql.SQLException

  Get a rows from the table by arbitrary where clause

### deleteRow

    public void deleteRow(java.lang.Object primaryValues)
                   throws java.sql.SQLException

  Delete a row from the table singular primary key

### deleteRows

    public void deleteRows(java.lang.Object[] primaryValues)
                    throws java.sql.SQLException

  Delete a row from the table by primary key values

### deleteRows

    public void deleteRows(ColumnGroup columns,
                           java.lang.Object[] values)
                    throws java.sql.SQLException

  Delete a row from the table by column group values

### deleteRows

    public void deleteRows(java.lang.String whereClause)
                    throws java.sql.SQLException

  Delete a row from the table by arbitrary WHERE clause

### database

    public Database database()

  Returns:
    The database for this table

### database

    public void database(Database db)

  Set the database used by this table. This can only be called if null was passed to the constructor

### create

    public java.lang.String create()

### drop

    public java.lang.String drop()

### toString

    public java.lang.String toString()

  Create table description
  Overrides:
    toString in class ColumnGroup

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD