org.objectweb.cjdbc.common.sql
Class CreateRequest

java.lang.Object
  extended byorg.objectweb.cjdbc.common.sql.AbstractRequest
      extended byorg.objectweb.cjdbc.common.sql.AbstractWriteRequest
          extended byorg.objectweb.cjdbc.common.sql.CreateRequest
All Implemented Interfaces:
java.io.Serializable

public class CreateRequest
extends AbstractWriteRequest
implements java.io.Serializable

A CreateRequest is a SQL request of the following syntax:

  CREATE [TEMPORARY] TABLE table-name [(column-name column-type [,column-name colum-type]* [,table-constraint-definition]*)]
 

Version:
1.0
Author:
Julie Marguerite , Mathieu Peltier , Emmanuel Cecchet
See Also:
Serialized Form

Field Summary
private  boolean alterDatabaseSchema
          alterDatabaseSchema is true if this create request alters the current database schema (using create table, create schema, create view) and false otherwise (create database, create index, create function, create method, create role, create trigger, create type).
private  boolean alterDefinitions
          alterDefinitions is true if this create request alters the current database definitions (using create function, create method, create trigger, create type) and false otherwise (create database, create table, create schema, create view, create index, create role).
private  java.util.ArrayList fromTables
          List of tables used to fill the created table in case of create query containing a select.
private static long serialVersionUID
           
private  DatabaseTable table
          The table to create.
 
Fields inherited from class org.objectweb.cjdbc.common.sql.AbstractWriteRequest
blocking, columns, pkValue, tableName
 
Fields inherited from class org.objectweb.cjdbc.common.sql.AbstractRequest
cacheable, cursorName, escapeProcessing, fetchSize, id, isAutoCommit, isParsed, isReadOnly, login, maxRows, requestType, sqlQuery, sqlSkeleton, timeoutInSeconds, transactionId, transactionIsolation
 
Constructor Summary
CreateRequest(CJDBCInputStream in)
           
CreateRequest(java.lang.String sqlQuery, boolean escapeProcessing, int timeout, java.lang.String lineSeparator)
          Creates a new CreateRequest instance.
CreateRequest(java.lang.String sqlQuery, boolean escapeProcessing, int timeout, java.lang.String lineSeparator, DatabaseSchema schema, int granularity, boolean isCaseSensitive)
          Creates a new CreateRequest instance.
 
Method Summary
 boolean altersDatabaseSchema()
          Returns true if this create request alters the current database schema (using create table, create schema, create view) and false otherwise (create database, create index, create function, create method, create procedure, create role, create trigger, create type).
 boolean altersDefinitions()
          Returns true if this create request alters the current database definitions (using create function, create method, create procedure, create trigger, create type) and false otherwise (create database, create table, create schema, create view, create index, create role).
 void cloneParsing(AbstractRequest request)
          Clones the parsing of a request.
 void debug()
          Displays some debugging information about this request.
 DatabaseTable getDatabaseTable()
          Gets the database table created by this statement (in case of a CREATE TABLE statement).
 java.util.ArrayList getFromTables()
          Returns the list of tables used to fill the created table in case of create query containing a select.
 boolean needsMacroProcessing()
          Returns true if this request requires macro (RAND(), NOW(), ...) processing.
 void parse(DatabaseSchema schema, int granularity, boolean isCaseSensitive)
          Parses the SQL request and extract the selected columns and tables given the DatabaseSchema of the database targeted by this request.
 boolean returnsResultSet()
          Does this request returns a ResultSet?
 
Methods inherited from class org.objectweb.cjdbc.common.sql.AbstractWriteRequest
cloneTableNameAndColumns, getColumns, getPk, getTableName, mightBlock, setBlocking
 
Methods inherited from class org.objectweb.cjdbc.common.sql.AbstractRequest
equals, getCacheAbility, getCursorName, getEscapeProcessing, getFetchSize, getId, getLineSeparator, getLogin, getMaxRows, getSQL, getSQLShortForm, getSqlSkeleton, getTimeout, getTransactionId, getTransactionIsolation, isAlter, isAutoCommit, isCreate, isDDL, isDelete, isDML, isDriverProcessed, isDrop, isInsert, isParsed, isReadOnly, isSelect, isUpdate, receiveResultSetParams, sendResultSetParams, sendToStream, setCacheAbility, setCursorName, setDriverProcessed, setFetchSize, setId, setIsAutoCommit, setIsReadOnly, setLogin, setMaxRows, setSQL, setSqlSkeleton, setTimeout, setTransactionId, setTransactionIsolation, trimCarriageReturnAndTabs
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

table

private transient DatabaseTable table
The table to create.


fromTables

private transient java.util.ArrayList fromTables
List of tables used to fill the created table in case of create query containing a select.


alterDatabaseSchema

private boolean alterDatabaseSchema
alterDatabaseSchema is true if this create request alters the current database schema (using create table, create schema, create view) and false otherwise (create database, create index, create function, create method, create role, create trigger, create type).

To force a refresh in case we don't understand the query, we default to true.


alterDefinitions

private boolean alterDefinitions
alterDefinitions is true if this create request alters the current database definitions (using create function, create method, create trigger, create type) and false otherwise (create database, create table, create schema, create view, create index, create role).

To force a refresh in case we don't understand the query, we default to true.

Constructor Detail

CreateRequest

public CreateRequest(java.lang.String sqlQuery,
                     boolean escapeProcessing,
                     int timeout,
                     java.lang.String lineSeparator,
                     DatabaseSchema schema,
                     int granularity,
                     boolean isCaseSensitive)
              throws java.sql.SQLException
Creates a new CreateRequest instance. The caller must give an SQL request, without any leading or trailing spaces and beginning with 'create table ' (it will not be checked).

If the syntax is incorrect an exception is thrown.

Parameters:
sqlQuery - the SQL request
escapeProcessing - should the driver to escape processing before sending to the database?
timeout - an int value
lineSeparator - the line separator used in the query
schema - a DatabaseSchema value
granularity - parsing granularity as defined in ParsingGranularities
isCaseSensitive - true if parsing is case sensitive
Throws:
java.sql.SQLException - if an error occurs

CreateRequest

public CreateRequest(java.lang.String sqlQuery,
                     boolean escapeProcessing,
                     int timeout,
                     java.lang.String lineSeparator)
Creates a new CreateRequest instance. The caller must give an SQL request, without any leading or trailing spaces and beginning with 'create table ' (it will not be checked).

The request is not parsed but it can be done later by a call to parse(DatabaseSchema, int, boolean).

Parameters:
sqlQuery - the SQL request
escapeProcessing - should the driver to escape processing before sending to the database ?
timeout - an int value
lineSeparator - the line separator used in the query
See Also:
parse(org.objectweb.cjdbc.common.sql.schema.DatabaseSchema, int, boolean)

CreateRequest

public CreateRequest(CJDBCInputStream in)
              throws java.io.IOException
See Also:
AbstractWriteRequest
Method Detail

parse

public void parse(DatabaseSchema schema,
                  int granularity,
                  boolean isCaseSensitive)
           throws java.sql.SQLException
Description copied from class: AbstractRequest
Parses the SQL request and extract the selected columns and tables given the DatabaseSchema of the database targeted by this request.

An exception is thrown when the parsing fails. Warning, this method does not check the validity of the request. In particular, invalid request could be parsed without throwing an exception. However, valid SQL request should never throw an exception.

Specified by:
parse in class AbstractRequest
Parameters:
schema - a DatabaseSchema value
granularity - parsing granularity as defined in ParsingGranularities
isCaseSensitive - true if parsing must be case sensitive
Throws:
java.sql.SQLException - if the parsing fails
See Also:
AbstractRequest.parse(org.objectweb.cjdbc.common.sql.schema.DatabaseSchema, int, boolean)

altersDatabaseSchema

public boolean altersDatabaseSchema()
Returns true if this create request alters the current database schema (using create table, create schema, create view) and false otherwise (create database, create index, create function, create method, create procedure, create role, create trigger, create type).

Returns:
Returns true if this query alters the database schema.

altersDefinitions

public boolean altersDefinitions()
Returns true if this create request alters the current database definitions (using create function, create method, create procedure, create trigger, create type) and false otherwise (create database, create table, create schema, create view, create index, create role).

Returns:
Returns true if this query alters database definitions.

cloneParsing

public void cloneParsing(AbstractRequest request)
Description copied from class: AbstractRequest
Clones the parsing of a request.

Specified by:
cloneParsing in class AbstractRequest
Parameters:
request - the parsed request to clone
See Also:
AbstractRequest.cloneParsing(AbstractRequest)

getDatabaseTable

public DatabaseTable getDatabaseTable()
Gets the database table created by this statement (in case of a CREATE TABLE statement).

Returns:
a DatabaseTable value

getFromTables

public java.util.ArrayList getFromTables()
Returns the list of tables used to fill the created table in case of create query containing a select.

Returns:
and ArrayList

needsMacroProcessing

public boolean needsMacroProcessing()
Description copied from class: AbstractRequest
Returns true if this request requires macro (RAND(), NOW(), ...) processing.

Specified by:
needsMacroProcessing in class AbstractRequest
Returns:
true if macro processing is required
See Also:
AbstractRequest.needsMacroProcessing()

returnsResultSet

public boolean returnsResultSet()
Description copied from class: AbstractRequest
Does this request returns a ResultSet?

Specified by:
returnsResultSet in class AbstractRequest
Returns:
true is this request will return a ResultSet
See Also:
AbstractRequest.returnsResultSet()

debug

public void debug()
Displays some debugging information about this request.

Overrides:
debug in class AbstractRequest


Copyright © 2002, 2005 - ObjectWeb Consortium - All Rights Reserved.