|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.objectweb.cjdbc.common.sql.AbstractRequest
An AbstractRequest
defines the skeleton of an SQL request.
Requests have to be serializable (at least) for inter-controller
communications.
Field Summary | |
protected int |
cacheable
Whether this request is cacheable or not. |
(package private) java.lang.String |
cursorName
|
private boolean |
driverProcessed
If set to true, this query is/was interpreted on the driver side, if false the various parameters are encoded and passed as is to the database native driver by the controller. |
protected boolean |
escapeProcessing
Should the backend driver do escape processing before sending to the database? |
(package private) int |
fetchSize
|
protected long |
id
Request unique id (set by the controller). |
protected boolean |
isAutoCommit
Whether this request has been sent in autocommit mode or
not. |
protected boolean |
isParsed
Whether the SQL content has been parsed or not. |
protected boolean |
isReadOnly
True if the connection has been set to read-only |
private java.lang.String |
lineSeparator
Set and sent by the driver to the controller. |
protected java.lang.String |
login
Login used to issue this request (must be set by the VirtualDatabaseWorkerThread). |
(package private) int |
maxRows
|
(package private) int |
requestType
|
protected java.lang.String |
sqlQuery
SQL query (should be set in constructor). |
protected java.lang.String |
sqlSkeleton
SQL query skeleton as it appears in PreparedStatements. |
protected int |
timeoutInSeconds
Timeout for this request in seconds, value 0 means no timeout (should be set in constructor). |
protected long |
transactionId
Transaction identifier if this request belongs to a transaction. |
protected int |
transactionIsolation
Transaction isolation level to use when executing the query inside a transaction. |
Constructor Summary | |
AbstractRequest(CJDBCInputStream in,
int requestType)
Creates a new AbstractRequest object, deserializing it from
an input stream. |
|
AbstractRequest(java.lang.String sqlQuery,
boolean escapeProcessing,
int timeout,
java.lang.String lineSeparator,
int requestType)
Default constructor Creates a new AbstractRequest object |
Method Summary | |
abstract void |
cloneParsing(AbstractRequest request)
Clones the parsing of a request. |
void |
debug()
Displays some debugging information about this request. |
boolean |
equals(java.lang.Object other)
Two requests are equal if they have the same SQL statement, transaction id and login. |
int |
getCacheAbility()
Returns the cacheable status of this request. |
java.lang.String |
getCursorName()
Returns the cursorName value. |
boolean |
getEscapeProcessing()
Returns true if the driver should escape processing before
sending to the database? |
int |
getFetchSize()
Returns the fetchSize value. |
long |
getId()
Returns the unique id of this request. |
java.lang.String |
getLineSeparator()
Returns the lineSeparator value. |
java.lang.String |
getLogin()
Returns the login used to issue this request. |
int |
getMaxRows()
Get the maximum number of rows the ResultSet can contain. |
java.lang.String |
getSQL()
Gets the SQL code of this request. |
java.lang.String |
getSQLShortForm(int nbOfCharacters)
Get a short form of this request if the SQL statement exceeds nbOfCharacters. |
java.lang.String |
getSqlSkeleton()
|
int |
getTimeout()
Gets the timeout for this request in seconds. |
long |
getTransactionId()
Gets the identifier of the transaction if this request belongs to a transaction, or -1 if this request does not belong to a transaction. |
int |
getTransactionIsolation()
Returns the transaction isolation level. |
boolean |
isAlter()
Returns true if this request in a ALTER
statement. |
boolean |
isAutoCommit()
Returns true if the request should be executed in
autocommit mode. |
boolean |
isCreate()
Returns true if this request in a CREATE
statement. |
boolean |
isDDL()
Returns true if this request is a DDL (Data Definition
Language) statement such as CREATE, ALTER or DROP. |
boolean |
isDelete()
Returns true if this request in a DELETE
statement. |
boolean |
isDML()
Returns true if this request is a DML (Data Manipulation
Language) statement such SELECT, INSERT, UPDATE or DELETE (see
http://www.orafaq.com/faq/Server_Utilities/SQL/faq53.htm)
Note that stored procedures are both considered as DDL and DML as they can
include both. |
boolean |
isDriverProcessed()
Returns the driverProcessed value. |
boolean |
isDrop()
Returns true if this request in a DROP
statement. |
boolean |
isInsert()
Returns true if this request in an INSERT
statement. |
boolean |
isParsed()
Returns true if the request SQL content has been already
parsed. |
boolean |
isReadOnly()
Returns true if the connection is set to read-only |
boolean |
isSelect()
Returns true if this request in a SELECT
statement. |
boolean |
isUpdate()
Returns true if this request in an UPDATE
statement. |
abstract boolean |
needsMacroProcessing()
Returns true if this request requires macro (RAND(), NOW(),
...) processing. |
abstract 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.
|
(package private) void |
receiveResultSetParams(CJDBCInputStream in)
Also fetch ResultSet parameters from the stream. |
private java.lang.String |
replaceStringWithSpace(java.lang.String s,
java.lang.String toReplace)
Replaces any given String by a space in a given
String . |
abstract boolean |
returnsResultSet()
Does this request returns a ResultSet? |
(package private) void |
sendResultSetParams(CJDBCOutputStream out)
Also serialize ResultSet parameters to the stream. |
void |
sendToStream(CJDBCOutputStream out,
boolean controllerWantsSqlSkeleton)
Serialize the request on the output stream by sending only the needed parameters to reconstruct it on the controller. |
void |
setCacheAbility(int cacheAbility)
Set the cacheable status of this request. |
void |
setCursorName(java.lang.String cursorName)
Sets the cursorName value. |
void |
setDriverProcessed(boolean driverProcessed)
Sets the driverProcessed value. |
void |
setFetchSize(int fetchSize)
Sets the fetchSize value. |
void |
setId(long id)
Sets the unique id of this request. |
void |
setIsAutoCommit(boolean isAutoCommit)
Sets the autocommit mode for this request. |
void |
setIsReadOnly(boolean isReadOnly)
Sets the read-only mode for this request. |
void |
setLogin(java.lang.String login)
Sets the login to use to issue this request. |
void |
setMaxRows(int rows)
Set the maximum number of rows in the ResultSet. |
void |
setSQL(java.lang.String sql)
Set the SQL code of this request. |
void |
setSqlSkeleton(java.lang.String skel)
|
void |
setTimeout(int timeout)
Sets the new timeout in seconds for this request. |
void |
setTransactionId(long id)
Sets the transaction identifier this request belongs to. |
void |
setTransactionIsolation(int isolationLevel)
Sets the transaction isolation level that must be used to execute this request |
java.lang.String |
trimCarriageReturnAndTabs()
If the query has a skeleton defined, return the skeleton with all carriage returns and tabs replaced with spaces. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
int requestType
RequestType
protected transient long id
protected java.lang.String sqlQuery
protected java.lang.String sqlSkeleton
protected java.lang.String login
protected int cacheable
protected boolean isParsed
int maxRows
int fetchSize
java.lang.String cursorName
protected boolean isReadOnly
protected boolean isAutoCommit
autocommit
mode or
not.
protected long transactionId
protected int transactionIsolation
protected int timeoutInSeconds
protected boolean escapeProcessing
Statement.setEscapeProcessing(boolean)
private java.lang.String lineSeparator
private boolean driverProcessed
Constructor Detail |
public AbstractRequest(java.lang.String sqlQuery, boolean escapeProcessing, int timeout, java.lang.String lineSeparator, int requestType)
AbstractRequest
object
sqlQuery
- the SQL queryescapeProcessing
- should the driver to escape processing before
sending to the database ?timeout
- an int
valuelineSeparator
- the line separator used in the queryrequestType
- the request type as defined in RequestType classRequestType
public AbstractRequest(CJDBCInputStream in, int requestType) throws java.io.IOException
AbstractRequest
object, deserializing it from
an input stream. Has to mirror the serialization method below.
in
- the input stream to read fromrequestType
- the request type as defined in RequestType class
java.io.IOException
- if a network error occursRequestType
Method Detail |
public void sendToStream(CJDBCOutputStream out, boolean controllerWantsSqlSkeleton) throws java.io.IOException
out
- destination CJDBCOutputStreamcontrollerWantsSqlSkeleton
- true if controller wants SQL templates
java.io.IOException
- if failsvoid receiveResultSetParams(CJDBCInputStream in) throws java.io.IOException
in
- input stream
java.io.IOException
- stream errorvoid sendResultSetParams(CJDBCOutputStream out) throws java.io.IOException
out
- output stream
java.io.IOException
- stream errorpublic abstract boolean needsMacroProcessing()
true
if this request requires macro (RAND(), NOW(),
...) processing.
true
if macro processing is requiredAbstractLoadBalancer.handleMacros(AbstractRequest)
public abstract boolean returnsResultSet()
public final boolean isAlter()
true
if this request in a ALTER
statement.
boolean
valuepublic final boolean isCreate()
true
if this request in a CREATE
statement.
boolean
valuepublic final boolean isDelete()
true
if this request in a DELETE
statement.
boolean
valuepublic final boolean isDDL()
true
if this request is a DDL (Data Definition
Language) statement such as CREATE, ALTER or DROP. Not supported yet are:
TRUNCATE, COMMENT, GRANT and REVOKE (see
http://www.orafaq.com/faq/Server_Utilities/SQL/faq53.htm)
Note that stored procedures are both considered as DDL and DML as they can include both.
public final boolean isDML()
true
if this request is a DML (Data Manipulation
Language) statement such SELECT, INSERT, UPDATE or DELETE (see
http://www.orafaq.com/faq/Server_Utilities/SQL/faq53.htm)
Note that stored procedures are both considered as DDL and DML as they can include both.
public final boolean isDrop()
true
if this request in a DROP
statement.
boolean
valuepublic final boolean isInsert()
true
if this request in an INSERT
statement.
boolean
valuepublic boolean isParsed()
true
if the request SQL content has been already
parsed.
boolean
valuepublic boolean isReadOnly()
true
if the connection is set to read-only
boolean
valuepublic final boolean isSelect()
true
if this request in a SELECT
statement.
boolean
valuepublic final boolean isUpdate()
true
if this request in an UPDATE
statement.
boolean
valuepublic void setIsReadOnly(boolean isReadOnly)
isReadOnly
- true
if connection is read-onlypublic int getCacheAbility()
RequestType.CACHEABLE
,
RequestType.UNCACHEABLE
or
RequestType.UNIQUE_CACHEABLE
int
valuepublic void setCacheAbility(int cacheAbility)
RequestType.CACHEABLE
,
RequestType.UNCACHEABLE
or
RequestType.UNIQUE_CACHEABLE
cacheAbility
- a int
valuepublic boolean getEscapeProcessing()
true
if the driver should escape processing before
sending to the database?
boolean
valuepublic long getId()
public void setId(long id)
id
- the id to setpublic boolean isAutoCommit()
true
if the request should be executed in
autocommit
mode.
boolean
valuepublic void setIsAutoCommit(boolean isAutoCommit)
isAutoCommit
- true
if autocommit
should
be usedpublic java.lang.String getLogin()
String
valuepublic java.lang.String getLineSeparator()
public void setLogin(java.lang.String login)
login
- a String
valuepublic java.lang.String getSQL()
public java.lang.String getSQLShortForm(int nbOfCharacters)
nbOfCharacters
- number of characters to include in the short form.
public int getMaxRows()
Statement.getMaxRows()
public void setMaxRows(int rows)
rows
- maximum number of rowsStatement.setMaxRows(int)
public void setSQL(java.lang.String sql)
parse(DatabaseSchema, int, boolean)
if needed.
sql
- SQL statementAbstractLoadBalancer.handleMacros(AbstractRequest)
public int getTimeout()
public void setTimeout(int timeout)
timeout
- an int
valueorg.objectweb.cjdbc.controller.scheduler
public long getTransactionId()
public void setTransactionId(long id)
id
- transaction idpublic boolean equals(java.lang.Object other)
other
- an object
boolean
valuepublic abstract void parse(DatabaseSchema schema, int granularity, boolean isCaseSensitive) throws java.sql.SQLException
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.
schema
- a DatabaseSchema
valuegranularity
- parsing granularity as defined in
ParsingGranularities
isCaseSensitive
- true if parsing must be case sensitive
java.sql.SQLException
- if the parsing failspublic abstract void cloneParsing(AbstractRequest request)
request
- the parsed request to clonepublic java.lang.String trimCarriageReturnAndTabs()
Note that if no modification has to be done, the original string is returned else a new string is constructed with the replaced elements.
private java.lang.String replaceStringWithSpace(java.lang.String s, java.lang.String toReplace)
String
by a space in a given
String
.
s
- the String
to transformtoReplace
- the String
to replace with spaces
String
public java.lang.String getSqlSkeleton()
PreparedStatement
.public void setSqlSkeleton(java.lang.String skel)
skel
- set the SQL query skeleton given in a
PreparedStatement
.public boolean isDriverProcessed()
public void setDriverProcessed(boolean driverProcessed)
driverProcessed
- The driverProcessed to set.public void setFetchSize(int fetchSize)
fetchSize
- The fetchSize to set.Statement
public int getFetchSize()
public int getTransactionIsolation()
public void setTransactionIsolation(int isolationLevel)
isolationLevel
- the transaction isolation levelpublic java.lang.String getCursorName()
public void setCursorName(java.lang.String cursorName)
cursorName
- The cursorName to set.public void debug()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |