org.apache.ddlutils.platform
Class SqlBuilder

java.lang.Object
  extended byorg.apache.ddlutils.platform.SqlBuilder
Direct Known Subclasses:
AxionBuilder, CloudscapeBuilder, Db2Builder, FirebirdBuilder, HsqlDbBuilder, InterbaseBuilder, MckoiBuilder, MSSqlBuilder, MySqlBuilder, Oracle8Builder, PostgreSqlBuilder, SapDbBuilder, SybaseBuilder

public abstract class SqlBuilder
extends Object

This class is a collection of Strategy methods for creating the DDL required to create and drop databases and tables. It is hoped that just a single implementation of this class, for each database should make creating DDL for each physical database fairly straightforward. An implementation of this class can always delegate down to some templating technology such as Velocity if it requires. Though often that can be quite complex when attempting to reuse code across many databases. Hopefully only a small amount code needs to be changed on a per database basis. TODO: It might be useful to add foreignkey analysis for creation/dropping of tables

Version:
$Revision: 378736 $
Author:
James Strachan, John Marshall/Connectria, Thomas Dudziak

Field Summary
protected  org.apache.commons.logging.Log _log
          The Log to which logging calls will be made.
protected static String SIZE_PLACEHOLDER
          The placeholder for the size value in the native type spec.
 
Constructor Summary
SqlBuilder(PlatformInfo info)
          Creates a new sql builder.
 
Method Summary
protected  void addEscapedCharSequence(String charSequence, String escapedVersion)
          Adds a char sequence that needs escaping, and its escaped version.
 void alterDatabase(Database currentModel, Database desiredModel)
          Generates the DDL to modify an existing database so the schema matches the current specified database schema.
 void alterDatabase(Database currentModel, Database desiredModel, boolean doDrops, boolean modifyColumns)
          Generates the DDL to modify an existing database so the schema matches the current specified database schema.
 void alterDatabase(Database currentModel, Database desiredModel, CreationParameters params, boolean doDrops, boolean modifyColumns)
          Generates the DDL to modify an existing database so the schema matches the current specified database schema.
protected  void alterTable(Database currentModel, Table currentTable, Database desiredModel, Table desiredTable, boolean doDrops, boolean modifyColumns)
          Alters the given currently existing table object to match the given desired table object.
protected  boolean columnsDiffer(Column currentColumn, Column desiredColumn)
          Compares the current column in the database with the desired one.
 void createExternalForeignKeys(Database database)
          Creates the external foreignkey creation statements for all tables in the database.
 void createExternalForeignKeys(Database database, Table table)
          Creates external foreignkey creation statements if necessary.
 void createTable(Database database, Table table)
          Outputs the DDL to create the table along with any non-external constraints as well as with external primary keys and indices (but not foreign keys).
 void createTable(Database database, Table table, Map parameters)
          Outputs the DDL to create the table along with any non-external constraints as well as with external primary keys and indices (but not foreign keys).
 void createTables(Database database)
          Outputs the DDL required to drop and (re)create all tables in the database model.
 void createTables(Database database, boolean dropTables)
          Outputs the DDL required to drop (if requested) and (re)create all tables in the database model.
 void createTables(Database database, CreationParameters params, boolean dropTables)
          Outputs the DDL required to drop (if requested) and (re)create all tables in the database model.
 void dropExternalForeignKeys(Table table)
          Creates external foreignkey drop statements.
 void dropTable(Table table)
          Outputs the DDL to drop the table.
 void dropTables(Database database)
          Outputs the DDL required to drop the database.
protected  String escapeStringValue(String value)
          Escapes the necessary characters in given string value.
protected  String getColumnName(Column column)
          Returns the column name.
protected  String getConstraintName(String prefix, Table table, String secondPart, String suffix)
          Returns the constraint name.
 DefaultValueHelper getDefaultValueHelper()
          Returns the default value helper.
 String getDeleteSql(Table table, Map pkValues, boolean genPlaceholders)
          Creates the SQL for deleting an object from the specified table.
protected  String getDelimitedIdentifier(String identifier)
          Returns the delimited version of the identifier (if configured).
 String getForeignKeyName(Table table, ForeignKey fk)
          Returns the name to be used for the given foreign key.
 String getIndent()
          Returns the string used to indent the SQL.
protected  String getIndexName(Index index)
          Returns the index name.
 String getInsertSql(Table table, Map columnValues, boolean genPlaceholders)
          Creates the SQL for inserting an object into the specified table.
protected  String getNativeDefaultValue(Column column)
          Returns the native default value for the column.
protected  String getNativeType(Column column)
          Returns the database-native type for the given column.
 PlatformInfo getPlatformInfo()
          Returns the platform info object.
 String getSelectLastInsertId(Table table)
          Generates the SQL for querying the id that was created in the last insertion operation.
protected  String getSqlType(Column column)
          Returns the full SQL type specification (including size and precision/scale) for the given column.
protected  String getTableName(Table table)
          Returns the table name.
 String getUpdateSql(Table table, Map columnValues, boolean genPlaceholders)
          Creates the SQL for updating an object in the specified table.
protected  String getValueAsString(Column column, Object value)
          Generates the string representation of the given value.
 String getValueLocale()
          Returns the locale that is used for number and date formatting (when printing default values and in generates insert/update/delete statements).
 Writer getWriter()
          Returns the writer that the DDL is printed to.
protected  void print(String text)
          Prints some text.
protected  void printComment(String text)
          Prints an SQL comment to the current stream.
protected  void printEndOfStatement()
          Prints the end of statement text, which is typically a semi colon followed by a carriage return.
protected  void printIdentifier(String identifier)
          Prints the given identifier.
protected  void printIndent()
          Prints the characters used to indent SQL.
protected  void println()
          Prints a newline.
protected  void println(String text)
          Prints some text followed by a newline.
protected  void printlnIdentifier(String identifier)
          Prints the given identifier followed by a newline.
protected  void printStartOfEmbeddedStatement()
          Prints the start of an embedded statement.
 void setIndent(String indent)
          Sets the string used to indent the SQL.
 void setValueLocale(String localeStr)
          Sets the locale that is used for number and date formatting (when printing default values and in generates insert/update/delete statements).
 void setWriter(Writer writer)
          Sets the writer for printing the DDL to.
protected  String shortenName(String name, int desiredLength)
          Generates a version of the name that has at most the specified length.
protected  boolean shouldGeneratePrimaryKeys(Column[] primaryKeyColumns)
          Determines whether we should generate a primary key constraint for the given primary key columns.
protected  void writeColumn(Table table, Column column)
          Outputs the DDL for the specified column.
 void writeColumnAlterStmt(Table table, Column column, boolean isNewColumn)
          Generates the alter statement to add or modify a single column on a table.
protected  void writeColumnAutoIncrementStmt(Table table, Column column)
          Prints that the column is an auto increment column.
protected  void writeColumnDefaultValue(Table table, Column column)
          Prints the default value of the column.
 void writeColumnDropStmt(Table table, Column column)
          Generates the statement to drop an column from a table.
protected  void writeColumnNotNullableStmt()
          Prints that a column is not nullable.
protected  void writeColumnNullableStmt()
          Prints that a column is nullable.
protected  void writeColumns(Table table)
          Writes the columns of the given table.
protected  void writeEmbeddedForeignKeysStmt(Database database, Table table)
          Writes the foreign key constraints inside a create table () clause.
protected  void writeEmbeddedIndexCreateStmt(Table table, Index index)
          Writes the given embedded index of the table.
protected  void writeEmbeddedIndicesStmt(Table table)
          Writes the indexes embedded within the create table statement.
protected  void writeEmbeddedPrimaryKeysStmt(Table table)
          Writes the primary key constraints of the table inside its definition.
protected  void writeExternalForeignKeyCreateStmt(Database database, Table table, ForeignKey key)
          Writes a single foreign key constraint using a alter table statement.
protected  void writeExternalForeignKeyDropStmt(Table table, ForeignKey foreignKey)
          Generates the statement to drop a foreignkey constraint from the database using an alter table statement.
protected  void writeExternalIndexCreateStmt(Table table, Index index)
          Writes the given index of the table.
 void writeExternalIndexDropStmt(Table table, Index index)
          Generates the statement to drop a non-embedded index from the database.
protected  void writeExternalIndicesCreateStmt(Table table)
          Writes the indexes of the given table.
protected  void writeExternalPrimaryKeysCreateStmt(Table table)
          Writes the primary key constraints of the table as alter table statements.
protected  void writeForeignReferences(ForeignKey key)
          Writes a list of foreign references for the given foreign key.
protected  void writeLocalReferences(ForeignKey key)
          Writes a list of local references for the given foreign key.
protected  void writePrimaryKeyStmt(Table table, Column[] primaryKeyColumns)
          Writes a primary key statement for the given columns.
protected  void writeTableAlterStmt(Table table)
          Generates the first part of the ALTER TABLE statement including the table name.
protected  void writeTableComment(Table table)
          Outputs a comment for the table.
protected  void writeTableCreationStmtEnding(Table table, Map parameters)
          Writes the end of the table creation statement.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SIZE_PLACEHOLDER

protected static final String SIZE_PLACEHOLDER
The placeholder for the size value in the native type spec.

See Also:
Constant Field Values

_log

protected final org.apache.commons.logging.Log _log
The Log to which logging calls will be made.

Constructor Detail

SqlBuilder

public SqlBuilder(PlatformInfo info)
Creates a new sql builder.

Parameters:
info - The plaftform information
Method Detail

getPlatformInfo

public PlatformInfo getPlatformInfo()
Returns the platform info object.

Returns:
The info object

getWriter

public Writer getWriter()
Returns the writer that the DDL is printed to.

Returns:
The writer

setWriter

public void setWriter(Writer writer)
Sets the writer for printing the DDL to.

Parameters:
writer - The writer

getDefaultValueHelper

public DefaultValueHelper getDefaultValueHelper()
Returns the default value helper.

Returns:
The default value helper

getIndent

public String getIndent()
Returns the string used to indent the SQL.

Returns:
The indentation string

setIndent

public void setIndent(String indent)
Sets the string used to indent the SQL.

Parameters:
indent - The indentation string

getValueLocale

public String getValueLocale()
Returns the locale that is used for number and date formatting (when printing default values and in generates insert/update/delete statements).

Returns:
The locale or null if default formatting is used

setValueLocale

public void setValueLocale(String localeStr)
Sets the locale that is used for number and date formatting (when printing default values and in generates insert/update/delete statements).

Parameters:
localeStr - The new locale or null if default formatting should be used; Format is "language[_country[_variant]]"

addEscapedCharSequence

protected void addEscapedCharSequence(String charSequence,
                                      String escapedVersion)
Adds a char sequence that needs escaping, and its escaped version.

Parameters:
charSequence - The char sequence
escapedVersion - The escaped version

createTables

public void createTables(Database database)
                  throws IOException
Outputs the DDL required to drop and (re)create all tables in the database model.

Parameters:
database - The database model
Throws:
IOException

createTables

public void createTables(Database database,
                         boolean dropTables)
                  throws IOException
Outputs the DDL required to drop (if requested) and (re)create all tables in the database model.

Parameters:
database - The database
dropTables - Whether to drop tables before creating them
Throws:
IOException

createTables

public void createTables(Database database,
                         CreationParameters params,
                         boolean dropTables)
                  throws IOException
Outputs the DDL required to drop (if requested) and (re)create all tables in the database model.

Parameters:
database - The database
params - The parameters used in the creation
dropTables - Whether to drop tables before creating them
Throws:
IOException

alterDatabase

public void alterDatabase(Database currentModel,
                          Database desiredModel)
                   throws IOException
Generates the DDL to modify an existing database so the schema matches the current specified database schema. Drops and modifications will not be made.

Parameters:
currentModel - The current database schema
desiredModel - The desired database schema
Throws:
IOException

alterDatabase

public void alterDatabase(Database currentModel,
                          Database desiredModel,
                          boolean doDrops,
                          boolean modifyColumns)
                   throws IOException
Generates the DDL to modify an existing database so the schema matches the current specified database schema.

Parameters:
currentModel - The current database schema
desiredModel - The desired database schema
doDrops - Whether columns and indexes should be dropped if not in the new schema
modifyColumns - Whether columns should be altered for datatype, size as required
Throws:
IOException

alterDatabase

public void alterDatabase(Database currentModel,
                          Database desiredModel,
                          CreationParameters params,
                          boolean doDrops,
                          boolean modifyColumns)
                   throws IOException
Generates the DDL to modify an existing database so the schema matches the current specified database schema.

Parameters:
currentModel - The current database schema
desiredModel - The desired database schema
params - The parameters used in the creation of new tables. Note that for existing tables, parameters won't be applied
doDrops - Whether columns and indexes should be dropped if not in the new schema
modifyColumns - Whether columns should be altered for datatype, size as required
Throws:
IOException

alterTable

protected void alterTable(Database currentModel,
                          Table currentTable,
                          Database desiredModel,
                          Table desiredTable,
                          boolean doDrops,
                          boolean modifyColumns)
                   throws IOException
Alters the given currently existing table object to match the given desired table object.

Parameters:
currentModel - The current model
currentTable - The current table definition
desiredModel - The desired model
desiredTable - The desired table definition
doDrops - Whether columns and indexes should be dropped if not in the new schema
modifyColumns - Whether columns should be altered for datatype, size as required
Throws:
IOException

createTable

public void createTable(Database database,
                        Table table)
                 throws IOException
Outputs the DDL to create the table along with any non-external constraints as well as with external primary keys and indices (but not foreign keys).

Parameters:
database - The database model
table - The table
Throws:
IOException

createTable

public void createTable(Database database,
                        Table table,
                        Map parameters)
                 throws IOException
Outputs the DDL to create the table along with any non-external constraints as well as with external primary keys and indices (but not foreign keys).

Parameters:
database - The database model
table - The table
parameters - Additional platform-specific parameters for the table creation
Throws:
IOException

createExternalForeignKeys

public void createExternalForeignKeys(Database database)
                               throws IOException
Creates the external foreignkey creation statements for all tables in the database.

Parameters:
database - The database
Throws:
IOException

createExternalForeignKeys

public void createExternalForeignKeys(Database database,
                                      Table table)
                               throws IOException
Creates external foreignkey creation statements if necessary.

Parameters:
database - The database model
table - The table
Throws:
IOException

dropTables

public void dropTables(Database database)
                throws IOException
Outputs the DDL required to drop the database.

Parameters:
database - The database
Throws:
IOException

dropTable

public void dropTable(Table table)
               throws IOException
Outputs the DDL to drop the table.

Parameters:
table - The table to drop
Throws:
IOException

dropExternalForeignKeys

public void dropExternalForeignKeys(Table table)
                             throws IOException
Creates external foreignkey drop statements.

Parameters:
table - The table
Throws:
IOException

getInsertSql

public String getInsertSql(Table table,
                           Map columnValues,
                           boolean genPlaceholders)
Creates the SQL for inserting an object into the specified table. If values are given then a concrete insert statement is created, otherwise an insert statement usable in a prepared statement is build.

Parameters:
table - The table
columnValues - The columns values indexed by the column names
genPlaceholders - Whether to generate value placeholders for a prepared statement
Returns:
The insertion sql

getUpdateSql

public String getUpdateSql(Table table,
                           Map columnValues,
                           boolean genPlaceholders)
Creates the SQL for updating an object in the specified table. If values are given then a concrete update statement is created, otherwise an update statement usable in a prepared statement is build.

Parameters:
table - The table
columnValues - Contains the values for the columns to update, and should also contain the primary key values to identify the object to update in case genPlaceholders is false
genPlaceholders - Whether to generate value placeholders for a prepared statement (both for the pk values and the object values)
Returns:
The update sql

getDeleteSql

public String getDeleteSql(Table table,
                           Map pkValues,
                           boolean genPlaceholders)
Creates the SQL for deleting an object from the specified table. If values are given then a concrete delete statement is created, otherwise an delete statement usable in a prepared statement is build.

Parameters:
table - The table
pkValues - The primary key values indexed by the column names, can be empty
genPlaceholders - Whether to generate value placeholders for a prepared statement
Returns:
The delete sql

getValueAsString

protected String getValueAsString(Column column,
                                  Object value)
Generates the string representation of the given value.

Parameters:
column - The column
value - The value
Returns:
The string representation

getSelectLastInsertId

public String getSelectLastInsertId(Table table)
Generates the SQL for querying the id that was created in the last insertion operation. This is obviously only useful for pk fields that are auto-incrementing. A database that does not support this, will return null.

Parameters:
table - The table
Returns:
The sql, or null if the database does not support this

shortenName

protected String shortenName(String name,
                             int desiredLength)
Generates a version of the name that has at most the specified length.

Parameters:
name - The original name
desiredLength - The desired maximum length
Returns:
The shortened version

getTableName

protected String getTableName(Table table)
Returns the table name. This method takes care of length limitations imposed by some databases.

Parameters:
table - The table
Returns:
The table name

writeTableComment

protected void writeTableComment(Table table)
                          throws IOException
Outputs a comment for the table.

Parameters:
table - The table
Throws:
IOException

writeTableAlterStmt

protected void writeTableAlterStmt(Table table)
                            throws IOException
Generates the first part of the ALTER TABLE statement including the table name.

Parameters:
table - The table being altered
Throws:
IOException

writeTableCreationStmtEnding

protected void writeTableCreationStmtEnding(Table table,
                                            Map parameters)
                                     throws IOException
Writes the end of the table creation statement. Per default, only the end of the statement is written, but this can be changed in subclasses.

Parameters:
table - The table
parameters - Additional platform-specific parameters for the table creation
Throws:
IOException

writeColumns

protected void writeColumns(Table table)
                     throws IOException
Writes the columns of the given table.

Parameters:
table - The table
Throws:
IOException

getColumnName

protected String getColumnName(Column column)
                        throws IOException
Returns the column name. This method takes care of length limitations imposed by some databases.

Parameters:
column - The column
Returns:
The column name
Throws:
IOException

writeColumn

protected void writeColumn(Table table,
                           Column column)
                    throws IOException
Outputs the DDL for the specified column.

Parameters:
table - The table containing the column
column - The column
Throws:
IOException

writeColumnAlterStmt

public void writeColumnAlterStmt(Table table,
                                 Column column,
                                 boolean isNewColumn)
                          throws IOException
Generates the alter statement to add or modify a single column on a table.

Parameters:
table - The table the index is on
column - The column to drop
isNewColumn - Whether the column should be added
Throws:
IOException

writeColumnDropStmt

public void writeColumnDropStmt(Table table,
                                Column column)
                         throws IOException
Generates the statement to drop an column from a table.

Parameters:
table - The table the index is on
column - The column to drop
Throws:
IOException

getSqlType

protected String getSqlType(Column column)
Returns the full SQL type specification (including size and precision/scale) for the given column.

Parameters:
column - The column
Returns:
The full SQL type string including the size

getNativeType

protected String getNativeType(Column column)
Returns the database-native type for the given column.

Parameters:
column - The column
Returns:
The native type

getNativeDefaultValue

protected String getNativeDefaultValue(Column column)
Returns the native default value for the column.

Parameters:
column - The column
Returns:
The native default value

escapeStringValue

protected String escapeStringValue(String value)
Escapes the necessary characters in given string value.

Parameters:
value - The value
Returns:
The corresponding string with the special characters properly escaped

writeColumnDefaultValue

protected void writeColumnDefaultValue(Table table,
                                       Column column)
                                throws IOException
Prints the default value of the column.

Parameters:
table - The table
column - The column
Throws:
IOException

writeColumnAutoIncrementStmt

protected void writeColumnAutoIncrementStmt(Table table,
                                            Column column)
                                     throws IOException
Prints that the column is an auto increment column.

Parameters:
table - The table
column - The column
Throws:
IOException

writeColumnNullableStmt

protected void writeColumnNullableStmt()
                                throws IOException
Prints that a column is nullable.

Throws:
IOException

writeColumnNotNullableStmt

protected void writeColumnNotNullableStmt()
                                   throws IOException
Prints that a column is not nullable.

Throws:
IOException

columnsDiffer

protected boolean columnsDiffer(Column currentColumn,
                                Column desiredColumn)
Compares the current column in the database with the desired one. Type, nullability, size, scale, default value, and precision radix are the attributes checked. Currently default values are compared, and null and empty string are considered equal.

Parameters:
currentColumn - The current column as it is in the database
desiredColumn - The desired column
Returns:
true if the column specifications differ

getForeignKeyName

public String getForeignKeyName(Table table,
                                ForeignKey fk)
Returns the name to be used for the given foreign key. If the foreign key has no specified name, this method determines a unique name for it. The name will also be shortened to honor the maximum identifier length imposed by the platform.

Parameters:
table - The table for whith the foreign key is defined
fk - The foreign key
Returns:
The name

getConstraintName

protected String getConstraintName(String prefix,
                                   Table table,
                                   String secondPart,
                                   String suffix)
Returns the constraint name. This method takes care of length limitations imposed by some databases.

Parameters:
prefix - The constraint prefix, can be null
table - The table that the constraint belongs to
secondPart - The second name part, e.g. the name of the constraint column
suffix - The constraint suffix, e.g. a counter (can be null)
Returns:
The constraint name

writeEmbeddedPrimaryKeysStmt

protected void writeEmbeddedPrimaryKeysStmt(Table table)
                                     throws IOException
Writes the primary key constraints of the table inside its definition.

Parameters:
table - The table
Throws:
IOException

writeExternalPrimaryKeysCreateStmt

protected void writeExternalPrimaryKeysCreateStmt(Table table)
                                           throws IOException
Writes the primary key constraints of the table as alter table statements.

Parameters:
table - The table
Throws:
IOException

shouldGeneratePrimaryKeys

protected boolean shouldGeneratePrimaryKeys(Column[] primaryKeyColumns)
Determines whether we should generate a primary key constraint for the given primary key columns.

Parameters:
primaryKeyColumns - The pk columns
Returns:
true if a pk statement should be generated for the columns

writePrimaryKeyStmt

protected void writePrimaryKeyStmt(Table table,
                                   Column[] primaryKeyColumns)
                            throws IOException
Writes a primary key statement for the given columns.

Parameters:
table - The table
primaryKeyColumns - The primary columns
Throws:
IOException

getIndexName

protected String getIndexName(Index index)
                       throws IOException
Returns the index name. This method takes care of length limitations imposed by some databases.

Parameters:
index - The index
Returns:
The index name
Throws:
IOException

writeExternalIndicesCreateStmt

protected void writeExternalIndicesCreateStmt(Table table)
                                       throws IOException
Writes the indexes of the given table.

Parameters:
table - The table
Throws:
IOException

writeEmbeddedIndicesStmt

protected void writeEmbeddedIndicesStmt(Table table)
                                 throws IOException
Writes the indexes embedded within the create table statement.

Parameters:
table - The table
Throws:
IOException

writeExternalIndexCreateStmt

protected void writeExternalIndexCreateStmt(Table table,
                                            Index index)
                                     throws IOException
Writes the given index of the table.

Parameters:
table - The table
index - The index
Throws:
IOException

writeEmbeddedIndexCreateStmt

protected void writeEmbeddedIndexCreateStmt(Table table,
                                            Index index)
                                     throws IOException
Writes the given embedded index of the table.

Parameters:
table - The table
index - The index
Throws:
IOException

writeExternalIndexDropStmt

public void writeExternalIndexDropStmt(Table table,
                                       Index index)
                                throws IOException
Generates the statement to drop a non-embedded index from the database.

Parameters:
table - The table the index is on
index - The index to drop
Throws:
IOException

writeEmbeddedForeignKeysStmt

protected void writeEmbeddedForeignKeysStmt(Database database,
                                            Table table)
                                     throws IOException
Writes the foreign key constraints inside a create table () clause.

Parameters:
database - The database model
table - The table
Throws:
IOException

writeExternalForeignKeyCreateStmt

protected void writeExternalForeignKeyCreateStmt(Database database,
                                                 Table table,
                                                 ForeignKey key)
                                          throws IOException
Writes a single foreign key constraint using a alter table statement.

Parameters:
database - The database model
table - The table
key - The foreign key
Throws:
IOException

writeLocalReferences

protected void writeLocalReferences(ForeignKey key)
                             throws IOException
Writes a list of local references for the given foreign key.

Parameters:
key - The foreign key
Throws:
IOException

writeForeignReferences

protected void writeForeignReferences(ForeignKey key)
                               throws IOException
Writes a list of foreign references for the given foreign key.

Parameters:
key - The foreign key
Throws:
IOException

writeExternalForeignKeyDropStmt

protected void writeExternalForeignKeyDropStmt(Table table,
                                               ForeignKey foreignKey)
                                        throws IOException
Generates the statement to drop a foreignkey constraint from the database using an alter table statement.

Parameters:
table - The table
foreignKey - The foreign key
Throws:
IOException

printComment

protected void printComment(String text)
                     throws IOException
Prints an SQL comment to the current stream.

Parameters:
text - The comment text
Throws:
IOException

printStartOfEmbeddedStatement

protected void printStartOfEmbeddedStatement()
                                      throws IOException
Prints the start of an embedded statement.

Throws:
IOException

printEndOfStatement

protected void printEndOfStatement()
                            throws IOException
Prints the end of statement text, which is typically a semi colon followed by a carriage return.

Throws:
IOException

println

protected void println()
                throws IOException
Prints a newline.

Throws:
IOException

print

protected void print(String text)
              throws IOException
Prints some text.

Parameters:
text - The text to print
Throws:
IOException

getDelimitedIdentifier

protected String getDelimitedIdentifier(String identifier)
Returns the delimited version of the identifier (if configured).

Parameters:
identifier - The identifier
Returns:
The delimited version of the identifier unless the platform is configured to use undelimited identifiers; in that case, the identifier is returned unchanged

printIdentifier

protected void printIdentifier(String identifier)
                        throws IOException
Prints the given identifier. For most databases, this will be a delimited identifier.

Parameters:
identifier - The identifier
Throws:
IOException

printlnIdentifier

protected void printlnIdentifier(String identifier)
                          throws IOException
Prints the given identifier followed by a newline. For most databases, this will be a delimited identifier.

Parameters:
identifier - The identifier
Throws:
IOException

println

protected void println(String text)
                throws IOException
Prints some text followed by a newline.

Parameters:
text - The text to print
Throws:
IOException

printIndent

protected void printIndent()
                    throws IOException
Prints the characters used to indent SQL.

Throws:
IOException


Copyright © 2005 Apache Software Foundation. All Rights Reserved.