de.unidu.is.sql
Interface SQLFormatter

All Known Implementing Classes:
PDatalogSQLFormatter, SQLFormatterImplementation

public interface SQLFormatter

An interface of a formatter for SQL statements.

A formatter converts an abstract SQL statement into an SQL string suitable for a specific database. This allows for bridging the subtle differences in the SQL syntax of the different relational database management systems.

Since:
2003-11-25
Version:
$Revision: 1.6 $, $Date: 2005/03/14 17:33:14 $
Author:
Henrik Nottelmann

Method Summary
 void addIndex(java.lang.String tableName, java.lang.String indexName, java.lang.String[] cols, boolean[] textCols)
          Adds an index to the specified table.
 void clear(java.lang.String tableName)
          Clear the specified tables, which means deletes all rows.
 void close(java.sql.ResultSet rs)
          Closes the specified ResultSet.
 void create(java.lang.String tableName, java.lang.String[] cols, java.lang.String[] types)
          Creates a table.
 DB getDB()
          Returns the DB parameters.
 java.lang.String getSelect(SQL sql)
          Returns a concrete select statement for this DB, obtained from the specified abstract SQL select statement.
 void perform(SQL sql, java.lang.String resultTableName)
          Transforms the specified abstract SQL insert statement into a concrete SQL statement for this DB, and performs it.
 java.sql.ResultSet performQuery(SQL sql)
          Transforms the specified abstract SQL select statement into a concrete SQL statement for this DB, performs it, and returns a corresponding ResultSet.
 void remove(java.lang.String tableName)
          Removes the specified table.
 void setDB(DB db)
          Sets the DB parameters.
 

Method Detail

create

public void create(java.lang.String tableName,
                   java.lang.String[] cols,
                   java.lang.String[] types)
Creates a table.

Parameters:
tableName - name of the table
cols - names of the columns
types - types of the columns, can be subject to substitution

clear

public void clear(java.lang.String tableName)
Clear the specified tables, which means deletes all rows.

Parameters:
tableName - name of the table

perform

public void perform(SQL sql,
                    java.lang.String resultTableName)
Transforms the specified abstract SQL insert statement into a concrete SQL statement for this DB, and performs it.

Parameters:
sql - abstract SQL statement
resultTableName - name of the result table (if null, the insert name from the SQL statement will be used)

performQuery

public java.sql.ResultSet performQuery(SQL sql)
                                throws java.sql.SQLException
Transforms the specified abstract SQL select statement into a concrete SQL statement for this DB, performs it, and returns a corresponding ResultSet.

Parameters:
sql - abstract SQL statement
Returns:
result set
Throws:
java.sql.SQLException

close

public void close(java.sql.ResultSet rs)
Closes the specified ResultSet.

Parameters:
rs - result set

getSelect

public java.lang.String getSelect(SQL sql)
Returns a concrete select statement for this DB, obtained from the specified abstract SQL select statement.

Parameters:
sql - abstract SQL statement
Returns:
concrete select statement for this DB

remove

public void remove(java.lang.String tableName)
Removes the specified table.

Parameters:
tableName - name of the table to remove

addIndex

public void addIndex(java.lang.String tableName,
                     java.lang.String indexName,
                     java.lang.String[] cols,
                     boolean[] textCols)
Adds an index to the specified table.

Parameters:
tableName - name of the table
indexName - name of the new index
cols - imvolved columns
textCols - flag indicating that the column is a text column

getDB

public DB getDB()
Returns the DB parameters.

Returns:
DB parameters

setDB

public void setDB(DB db)
Sets the DB parameters.

Parameters:
db - DB parameters