OpMath

com.opmath.util.db
Interface DB

All Known Subinterfaces:
DBRemote
All Known Implementing Classes:
DBObject, DBRemoteObject

public interface DB

The interface that must be implemented for any JDBC driver that can support OpMath Data Platform operations.

Classes implementing DB are assumed to be in-process or embedded drivers.

Copyright: (c) 2002 The Open Math Company Limited

The Terms of Distribution of this software are stipulated in the javadoc Overview for this project.

Since:
JDBC 2.0, J2SE 1.3
Version:
utilities-v011
Author:
Bruno Beloff bruno.beloff@opmath.com

Method Summary
 String className()
          Returns the name of the class of this DBObject object.
 void close()
          Shut down the database server or driver.
 void connect(String user, String pass)
          Establish a connection to the database.
 void create(String table, String values)
          Creates a new row in the named table.
 void createTable(String table, String sql)
          Creates a new table within this database.
 void delete(String table, String keyName, long keyValue)
          Deletes the row (or rows) with the specfied key name and value, in the named table.
 void delete(String table, String keyName, String keyValue)
          Deletes the row (or rows) with the specfied key name and value, in the named table.
 void dropTable(String table)
          Deletes a table within this database.
 Connection getConnection()
          Returns the connection object for this DB instance.
 Class getDriver()
          Returns the driver class of this DB.
 String getPath()
          Returns the fully qualified path for the current connection.
 String getProtocol()
          Returns the protocol for the current connection.
 boolean isAvailable()
          Tests whether the database is responding.
 String maxIndex(String table, String pkName)
          Returns the highest value of the primary key for the named table.
 ResultSet query(String table, String where, String order)
          Returns the rows from the named table, as found by the ad hoc query given in sql.
 ResultSet read(String table, String keyName, long keyValue)
          Returns the rows from the named table whose field keyName exactly matches keyValue.
 ResultSet read(String table, String keyName, String keyValue)
          Returns the rows from the named table whose field keyName exactly matches keyValue.
 ResultSet readAll(String table, String order)
          Returns all of the rows from the named table.
 void update(String table, String pkName, long pkValue, String set)
          Updates the row with the specfied primary key name and value, in the named table.
 void update(String table, String pkName, String pkValue, String set)
          Updates the row with the specfied primary key name and value, in the named table.
 

Method Detail

connect

public void connect(String user,
                    String pass)
             throws SQLException

Establish a connection to the database. By default, autoCommit will be set to true.

NOTE: It is assumed that only one simultaneous connection can be held by any DB instance.

Throws:
SQLException - if the connection could not be made.
SQLException
Since:
JDBC 2.0, J2SE 1.3
See Also:
Connection.setAutoCommit(boolean)

close

public void close()
           throws SQLException

Shut down the database server or driver.

Throws:
SQLException - if the database could not be shut down.
SQLException
Since:
JDBC 2.0, J2SE 1.3

isAvailable

public boolean isAvailable()

Tests whether the database is responding.

Returns:
A boolean indicating database availability.
Since:
JDBC 2.0, J2SE 1.3

getDriver

public Class getDriver()
                throws ClassNotFoundException

Returns the driver class of this DB.

Returns:
A Class representing the database driver.
Throws:
ClassNotFoundException - if the driver class cannot be found.
ClassNotFoundException
Since:
JDBC 2.0, J2SE 1.3

getProtocol

public String getProtocol()

Returns the protocol for the current connection. Returns null if there is no current connection.

Returns:
A Class representing the database driver.
Since:
JDBC 2.0, J2SE 1.3

getPath

public String getPath()

Returns the fully qualified path for the current connection. Returns null if there is no current connection.

Returns:
A Class representing the database driver.
Since:
JDBC 2.0, J2SE 1.3

getConnection

public Connection getConnection()
                         throws SQLException

Returns the connection object for this DB instance.

Returns:
A Connection object.
Throws:
SQLException - if the connection could not be made.
SQLException
Since:
JDBC 2.0, J2SE 1.3

className

public String className()

Returns the name of the class of this DBObject object.

Returns:
A String naming the class.
Since:
JDBC 2.0, J2SE 1.3

createTable

public void createTable(String table,
                        String sql)
                 throws SQLException

Creates a new table within this database.

Throws:
SQLException - if the table could not be created.
SQLException
Since:
JDBC 2.0, J2SE 1.3

dropTable

public void dropTable(String table)
               throws SQLException

Deletes a table within this database.

Throws:
SQLException - if the table could not be deleted.
SQLException
Since:
JDBC 2.0, J2SE 1.3

maxIndex

public String maxIndex(String table,
                       String pkName)
                throws SQLException

Returns the highest value of the primary key for the named table. The value is returned as a String, irrespective of its actual stored type.

Throws:
SQLException - if the operation could not be completed.
SQLException
Since:
JDBC 2.0, J2SE 1.3

create

public void create(String table,
                   String values)
            throws SQLException

Creates a new row in the named table.

The String values is used within the VALUES(..) SQL sub-clause of the INSERT statement, and is a comma-separated list of values that must be appropriate to the table definition.

Throws:
SQLException - if the create operation could not be completed.
SQLException
Since:
JDBC 2.0, J2SE 1.3

read

public ResultSet read(String table,
                      String keyName,
                      long keyValue)
               throws SQLException

Returns the rows from the named table whose field keyName exactly matches keyValue.

Returns:
A ResultSet carrying the retrieved data.
Throws:
SQLException - if the read operation could not be completed.
SQLException
Since:
JDBC 2.0, J2SE 1.3

read

public ResultSet read(String table,
                      String keyName,
                      String keyValue)
               throws SQLException

Returns the rows from the named table whose field keyName exactly matches keyValue.

Returns:
A ResultSet carrying the retrieved data.
Throws:
SQLException - if the read operation could not be completed.
SQLException
Since:
JDBC 2.0, J2SE 1.3

readAll

public ResultSet readAll(String table,
                         String order)
                  throws SQLException

Returns all of the rows from the named table.

The String order is a comma-seperated list of field names (most significant field first), each with sort direction.

Returns:
A ResultSet carrying the retrieved data.
Throws:
SQLException - if the read operation could not be completed.
SQLException
Since:
JDBC 2.0, J2SE 1.3

query

public ResultSet query(String table,
                       String where,
                       String order)
                throws SQLException

Returns the rows from the named table, as found by the ad hoc query given in sql. The String where is used within the WHERE SQL sub-clause of the SELECT statement.

The String order is a comma-seperated list of field names (most significant field first), each with sort direction.

Returns:
A ResultSet carrying the retrieved data.
Throws:
SQLException - if the query operation could not be completed.
SQLException
Since:
JDBC 2.0, J2SE 1.3

update

public void update(String table,
                   String pkName,
                   long pkValue,
                   String set)
            throws SQLException

Updates the row with the specfied primary key name and value, in the named table. The String where is used within the SET SQL sub-clause of the UPDATE statement.

Throws:
SQLException - if the update operation could not be completed.
SQLException
Since:
JDBC 2.0, J2SE 1.3

update

public void update(String table,
                   String pkName,
                   String pkValue,
                   String set)
            throws SQLException

Updates the row with the specfied primary key name and value, in the named table. The String where is used within the SET SQL sub-clause of the UPDATE statement.

Throws:
SQLException - if the update operation could not be completed.
SQLException
Since:
JDBC 2.0, J2SE 1.3

delete

public void delete(String table,
                   String keyName,
                   long keyValue)
            throws SQLException

Deletes the row (or rows) with the specfied key name and value, in the named table.

Throws:
SQLException - if the delete operation could not be completed.
SQLException
Since:
JDBC 2.0, J2SE 1.3

delete

public void delete(String table,
                   String keyName,
                   String keyValue)
            throws SQLException

Deletes the row (or rows) with the specfied key name and value, in the named table.

Throws:
SQLException - if the delete operation could not be completed.
SQLException
Since:
JDBC 2.0, J2SE 1.3

OpMath

Submit a bug or feature to Open Math
Copyright © 2002 Open Math Company Limited, Brighton, UK