Top Description Inners Fields Constructors Methods
org.apache.derby.impl.drda

pack-priv Class DRDAStatement

extends Object
Class Inheritance
Imports
java.io.IOException, java.lang.reflect.Array, .Method, java.math.BigInteger, java.sql.CallableStatement, .Connection, .DataTruncation, .ParameterMetaData, .PreparedStatement, .ResultSet, .SQLException, .Statement, java.util.ArrayList, .Hashtable, org.apache.derby.iapi.jdbc.EngineStatement, .EnginePreparedStatement, org.apache.derby.iapi.transaction.TransactionControl, org.apache.derby.iapi.util.StringUtil, org.apache.derby.impl.jdbc.Util

DRDAStatement stores information about the statement being executed

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
DRDAStatement.DrdaParamState

This class is used to keep track of the statement's parameters as they are received from the client.

Field Summary

Modifier and TypeField and Description
protected int
protected int
protected int
protected String
protected int
protected String
protected int
protected String
protected int
private DRDAResultSet
protected String
protected Database
private DRDAStatement.DrdaParamState
pack-priv boolean
protected boolean
protected int
protected int
protected int
protected int
pack-priv boolean
protected static int
private int
protected int
protected boolean
private int[]
private int[]
private int[]
private Pkgnamcsn
protected String
protected EnginePreparedStatement
private int
protected boolean
protected int
private ArrayList<ConsistencyToken>
resultSetKeyList

Ordered list of hash keys.

private Hashtable<ConsistencyToken, DRDAResultSet>
resultSetTable

Hashtable with resultsets.

protected long
protected byte[]
protected int
pack-priv int
sqldaType

Saved value returned from DRDAConnThread#parsePRPSQLSTT.

private EngineStatement
protected ParameterMetaData
private DataTruncation
truncationWarnings

A chain of warnings indicating whether some of the data values returned by this statement had to be truncated before being sent to the client.

protected String
pack-priv long
versionCounter

If this changes, we need to re-send result set metadata to client, since a change indicates the engine has recompiled the prepared statement.

pack-priv int

Constructor Summary

AccessConstructor and Description
pack-priv
DRDAStatement(Database database)

DRDAStatement constructor

Method Summary

Modifier and TypeMethod and Description
protected void
addDrdaParam(byte
- type of the parameter
t
,
int
- length in bytes of the parameter
l
)

Add another parameter to this statement.

protected void
addExtDtaObject(Object
- object to add
o
,
int
- jdbc index for parameter
jdbcIndex
)

Add extDtaObject

protected void
addExtPosition(int
- zero-based index into list of external parameters
pos
)

Mark the pos'th parameter as external

protected ConsistencyToken

Returns:

Consistency token for this resultSet For a single resultSet that is the same as the statement's For multiple resultSets just the consistency token is changed
addResultSet
(ResultSet
- ResultSet to add
value
,
int
- Holdability of the ResultSet
holdValue
)

Add a new resultSet to this statement.

protected void
addTruncationWarning(DataTruncation
the warning to add
w
)

Add a warning about data having been truncated.

protected ConsistencyToken

Returns:

Consistency token for result set
calculateResultSetPkgcnstkn
(int
- result set # starting with 0
rsNum
)

For a single result set, just echo the consistency token that the client sent us.

protected void
clearDrdaParams()

Clears the parameter state (type, length and ext information) stored in this statement, but does not release any storage.

protected void
clearExtDtaObjects()

Clear externalized lob objects in current result set

protected void
clearTruncationWarnings()

Clear the chain of truncation warnings for this statement.

protected void
close()

This method closes the JDBC objects and frees up all references held by this object.

protected void
CLSQRY()

Explicitly close the result set by CLSQRY needed to check for double close.

protected boolean

Returns:

true if the execution has resultSets
execute
()

Executes the prepared statement and populates the resultSetTable.

protected PreparedStatement
protected void
finishParams()

clear out type data for parameters.

protected int
protected int
protected DRDAResultSet

Returns:

DRDAResultSet
getCurrentDrdaResultSet
()

Gets the current DRDA ResultSet

protected int

Returns:

the number of parameters
getDrdaParamCount
()

Get the number of parameters, internal and external, that has been added to this statement.

private DRDAResultSet
private DRDAResultSet
getDrdaResultSet(int rsNum)

protected ArrayList<Object>

Returns:

ArrayList with extdta
getExtDtaObjects
()

Get the extData Objects

protected int

Returns:

the parameter position of the i'th external parameter
getExtPosition
(int
- zero-based index into list of external parameters
i
)

Get the parameter position of the i'th external parameter

protected int

Returns:

the number of external parameters
getExtPositionCount
()

Get the number of external parameters in this statement.

private boolean

Returns:

true if there are more results.
getMoreResults
(int
- flag to pass to Statement.getMoreResults(current)
current
)

get more results using reflection.

protected int

Returns:

number of result sets
getNumResultSets
()

protected int

Returns:

number of columns
getNumRsCols
()

get the number of result set columns for the current resultSet

protected int[]
protected static int

Returns:

type from java.sql.Types
getOutputParameterTypeFromClassName
(String
Class name of object being evaluated. indicating if this an output parameter
objectName
)

Given an object class name get the paramameter type if the parameter mode is unknown.

pack-priv int

Returns:

precision or NOT_OUTPUT_PARAM if this is not an output parameter
getOutputParamPrecision
(int
- parameter number starting with 1
paramNum
)

get precision for output parameter.

pack-priv int

Returns:

scale or NOT_OUTPUT_PARAM if this is not an output parameter
getOutputParamScale
(int
- parameter number starting with 1
paramNum
)

get scale for output parameter.

pack-priv int

Returns:

jdbcType or NOT_OUTPUT_PARAM if this is not an output parameter
getOutputParamType
(int
- parameter number starting with 1
paramNum
)

get type for output parameter.

protected int

Returns:

DRDA Type of column
getParamDRDAType
(int
- starting with 1
index
)

get parameter DRDAType

protected ParameterMetaData

Returns:

ParameterMetaData for the prepared statement.

Note

there is no separate BrokeredParameterSetMetaData.

getParameterMetaData
()

Retrieve the ParameterMetaData for the prepared statement.

protected int

Returns:

data length
getParamLen
(int
- starting with 1
index
)

returns drda length of parameter as sent by client.

protected int

Returns:

precision
getParamPrecision
(int
parameter index starting with 1
index
)

get parameter precision or DB2 max (31)

protected int

Returns:

scale
getParamScale
(int
parameter index starting with 1
index
)

get parameter scale or DB2 max (31)

protected Pkgnamcsn

Returns:

pkgnamcsn
getPkgnamcsn
()

Get pkgnamcsn

protected EnginePreparedStatement

Returns:

prepared statement
getPreparedStatement
()

Get prepared statement

protected int
protected long
protected int
protected boolean
protected int
protected ResultSet

Returns:

result set
getResultSet
()

Get result set

public String
getResultSetCursorName(int
- result set # starting with 0
rsNum
)

protected ConsistencyToken

Returns:

consistency token (key) for the result set
getResultSetPkgcnstkn
(int
result set starting with 0
rsNum
)

protected int

Returns:

DRDA Type of column
getRsDRDAType
(int
- starting with 1
index
)

get resultset/out parameter DRDAType

protected int[]

Returns:

ResultSet DRDA DataTypes
getRsDRDATypes
()

protected int

Returns:

length of drda data
getRsLen
(int
starting with 1
index
)

get resultset/out parameter DRDALen

protected int

Returns:

precision of column
getRsPrecision
(int
-starting with 1
index
)

get resultset /out parameter precision

protected int

Returns:

scale of column
getRsScale
(int
-starting with 1
index
)

get resultset /out parameter scale

protected int
public byte[]
private String

Returns:

SQL text
getSQLText
()

Use reflection to retrieve SQL Text for EmbedPreparedStatement or BrokeredPreparedStatement.

protected EngineStatement

Returns:

statement
getStatement
()

Get the statement

private int

Returns:

isolation
getStaticPackageIsolation
(String
- Package identifier string (e.g. SYSSTAT)
pkgid
)

get the isolation level for a static package.

protected DataTruncation

Returns:

chain of truncation warnings, possibly null
getTruncationWarnings
()

Get the chain of truncation warnings added to this statement.

protected boolean
protected boolean
protected void
initialize()

This method is used to initialize the default statement of the database for re-use.

private boolean
protected boolean
private boolean
protected boolean
pack-priv boolean
isOutputParam(int
parameter number starting with 1. return true if this is an output parameter.
paramNum
)

is parameter an ouput parameter

pack-priv boolean

Returns:

implicit close boolean
isRSCloseImplicit
(boolean
true if the client expects QRYCLSIMP to be respected for the LMTBLKPRC protocol
lmtblkprcOK
)

Method to decide whether the ResultSet should be closed implicitly based on the QRYCLSIMP value sent from the client.

protected boolean
isScrollable()

is this a scrollable cursor?

private void
protected PreparedStatement
prepare(String
- SQL statement
sqlStmt
)

Create a prepared statement

public void
public void
registerOutParam(int paramNum)

protected void
reset()

This method resets the state of this DRDAStatement object so that it can be re-used.

protected void
rsClose()

Close the current resultSet

protected boolean

Returns:

whether the statement is closed
rsIsClosed
()

is Statement closed

protected void
rsSuspend()

Set state to SUSPENDED (result set is opened)

protected void
setConcurType(int scrollType)

protected void
setCurrentDrdaResultSet(int
The result set number starting with 0
rsNum
)

Set currentDrdaResultSet

protected void
setCurrentDrdaResultSet(Pkgnamcsn
The pkgid section number and unique resultset consistency token
pkgnamcsn
)

Set currentDrdaResultSet

protected void
setDatabase(Database database)

Set database

protected void
setHasdata(boolean hasdata)

protected void
setOPNQRYOptions(int
QRYBLKSZ (Query Block Size)
blksize
,
int
QRYPRCTYP (Query Protocol Type)
qryblkctl
,
int
MAXBLKEXT (Maximum Number of Extra Blocks)
maxblkext
,
int
OUTOVROPT (Output Override Option)
outovropt
,
int
QRYROWSET (Query Rowset Size)
qryrowset
,
int
QRYCLSIMP (Query Close Implicit)
qryclsimpl
)

Set query options sent on OPNQRY and pass options down to the current DRDAResultSet object.

protected void
setOutovr_drdaType(int[] outovr_drdaType)

protected void
setPkgnamcsn(Pkgnamcsn
package id section number and token from the client
pkgnamcsn
)

Set the pkgid sec num for this statement and the consistency token that will be used for the first resultSet.

protected void
setQryprctyp(int qryprctyp)

protected void
setQryrownbr(long qryrownbr)

protected void
setQryrtndta(boolean qryrtndta)

protected void
setQryscrorn(int qryscrorn)

protected void
setQueryOptions(int blksize, boolean qryrelscr, long qryrownbr, boolean qryfrtbl, int nbrrow, int maxblkext, int qryscrorn, boolean qryrowsns, boolean qryblkrst, boolean qryrtndta, int qryrowset, int rtnextdta)

protected void
setRsDefaultOptions(DRDAResultSet drs)

Set resultSet defaults to match the statement defaults sent on EXCSQLSTT This might be overridden on OPNQRY or CNTQRY

protected void
setRsDRDAType(int
- starting with 1
index
,
int type)

set result DRDAType

protected void
setRsPrecision(int
- starting with 1
index
,
int precision)

set resultset/out parameter precision

protected void
setRsScale(int
- starting with 1
index
,
int scale)

set resultset/out parameter scale

protected void
setScrollType(int scrollType)

public void
setSplitQRYDTA(byte[] data)

protected void
setStatement(Connection
Connection
conn
)

Set statement

protected void
protected void
setTypDefValues()

set TypDef values

private void
protected String
protected boolean
protected boolean
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait