: Class DbAdaptor

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 DbAdaptor

    java.lang.Object
      |
      +--com.mortbay.JDBC.DbAdaptor

Direct Known Subclasses:
  CloudscapeAdaptor, MsqlAdaptor, OracleAdaptor

public class DbAdaptor
extends java.lang.Object

An adaptor class for JDBC drivers

this class provides helper functions to handle the differences in JDBC drivers.

Specifically it provides help with data types, quoting strings and allow table creation from java described meta data (the opposite of the intended JDBC style where the driver provides an often unimplemented API to access the metadata).

The default implementation is for a standard ANSI SQL database whose JDBC driver is specified by the java property "DbDriver" This class must be specialized to handle any specific behaviour of a particular DB/JDBCdriver combination and the derived class name should be passed to the constructor of Database

Version:
  $Revision: 2.4 $ $Date: 2000/10/20 16:44:50 $
Author:
  Greg Wilkins (gregw)
See Also:
  `Database`

Field Summary
`protected java.lang.String` | `dbDriver`

Constructor Summary
`DbAdaptor()` Constructor.

Method Summary
`java.lang.String` | `columnType(int type)` Map the a column type to database column type.
`java.lang.String` | `formatColumnValue(Column column, java.lang.Object value)` Format a column value
`java.lang.String` | `formatCreateIndex(Table table)` Format the index creation statements for a table
`java.lang.String` | `formatCreateTable(Table table)` Format a table create statement.
`java.lang.String` | `formatKeys(Table table)` Format the key columns for a table Return string describing the key columns for a CREATE statement.
`java.lang.String` | `formatTable(Table table)` Format table columns
`java.lang.String` | `getJdbcDriver()` Get the JDBC driver class name for this adaptor.
`java.lang.String` | `go()` The go string
`java.lang.Object` | `nullColumnValue(Column column)` A null value for the column
`java.lang.String` | `primaryMarker()` The marker used when creating a table to mark a primary key.
`java.lang.String` | `quote(java.lang.String s)` Quote a string value for the database.

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

Field Detail

### dbDriver

    protected java.lang.String dbDriver

Constructor Detail

### DbAdaptor

    public DbAdaptor()

  Constructor. Select DbDriver from java property DbDriver

Method Detail

### getJdbcDriver

    public java.lang.String getJdbcDriver()

  Get the JDBC driver class name for this adaptor.
  Returns:

### quote

    public java.lang.String quote(java.lang.String s)

  Quote a string value for the database.
  Parameters:
    `s` - A string
  Returns:
    The string in quotes with any internal special characters handled.

### columnType

    public java.lang.String columnType(int type)

  Map the a column type to database column type.
  Parameters:
    `type` - The column type (see Column)
  Returns:
    Column type name recognized by underlying database.

### formatColumnValue

    public java.lang.String formatColumnValue(Column column,
                                              java.lang.Object value)

  Format a column value
  Parameters:
    `column` - The column to format the value for
    `value` - The value of the column
  Returns:
    A string representing how the value should be presented to the underlying database (e.g. quoted string for VARCHAR).

### nullColumnValue

    public java.lang.Object nullColumnValue(Column column)

  A null value for the column
  Parameters:
    `column` - The Column
  Returns:
    An object which represents a null value for the java type used to handle the column type.

### primaryMarker

    public java.lang.String primaryMarker()

  The marker used when creating a table to mark a primary key.
  Returns:
    The default implementation returns "NOT NULL"

### go

    public java.lang.String go()

  The go string
  Returns:
    The string used by the underlying database to trigger handling of meta data commands. Default is "go".

### formatKeys

    public java.lang.String formatKeys(Table table)

  Format the key columns for a table Return string describing the key columns for a CREATE statement.
  Parameters:
    `table` - The table
  Returns:
    default returns "primary key ( column [,...] )"

### formatTable

    public java.lang.String formatTable(Table table)

  Format table columns
  Parameters:
    `table` - The table
  Returns:
    A text description of the tables columns suitable for inclusion in a CREATE statement.

### formatCreateTable

    public java.lang.String formatCreateTable(Table table)

  Format a table create statement.
  Parameters:
    `table` - The table
  Returns:
    A CREATE statement for the table.

### formatCreateIndex

    public java.lang.String formatCreateIndex(Table table)

  Format the index creation statements for a table
  Parameters:
    `table` - The Table
  Returns:
    Index creation statements for the table.

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