|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsqlg2.GBase
public class GBase
Base class for all classes which are processed by preprocessor. Wraps access to JDBC methods allowing preprocessor to intercept them and extract required information. This class itself is not thread-safe, so it cannot be used by more than one thread at a time. Use wrappers generated by preprocessor to access business methods.
Field Summary | |
---|---|
static java.lang.String[] |
ALL_KEYS
Use it for autoKeys parameter of prepareStatementKey(String[], String) to
retrieve all generated columns. |
Constructor Summary | |
---|---|
GBase(LocalWrapperBase lwb)
Constructor. |
Method Summary | ||
---|---|---|
java.lang.Object[] |
callStoredBlock(java.lang.String block,
java.lang.Object... in)
Executes PL/SQL block. |
|
java.lang.Object[] |
callStoredProc(java.lang.String name,
boolean block,
java.lang.Object... in)
Executes stored procedure or PL/SQL block (depending of block parameter). |
|
java.lang.Object[] |
callStoredProc(java.lang.String name,
java.lang.Object... in)
Calls stored procedure. |
|
void |
close(java.sql.ResultSet rs,
java.sql.Statement st)
Closes result set and statement. |
|
void |
close(java.sql.Statement st)
Closes statement. |
|
void |
closeStatements()
Closes all open statements (usually this method is called by wrappers automatically). |
|
|
columnOf(java.lang.Class<T> cls,
java.sql.PreparedStatement stmt)
Executes select query returning single column of T. |
|
double[] |
columnOfDouble(java.sql.PreparedStatement stmt)
Executes select query returning single column of double . |
|
int[] |
columnOfInt(java.sql.PreparedStatement stmt)
Executes select query returning single column of int . |
|
long[] |
columnOfLong(java.sql.PreparedStatement stmt)
Executes select query returning single column of long . |
|
java.lang.Object[] |
columnOfObject(java.sql.PreparedStatement stmt)
Executes select query returning single column of Object . |
|
java.lang.String[] |
columnOfString(java.sql.PreparedStatement stmt)
Executes select query returning single column of String . |
|
static QueryPiece |
createQueryPiece(QueryPiece query)
This is for preprocessor-generated QueryPieces (see Query ). |
|
static QueryPiece |
createQueryPiece(java.lang.String sql)
Creates piece of SQL query consisting only of text. |
|
static QueryPiece |
createQueryPiece(java.lang.String sql,
java.lang.Object[] params,
java.lang.Class<?>[] paramTypes)
This is for preprocessor-generated QueryPieces (see Query ). |
|
static QueryPiece |
createQueryPiece(java.lang.String sql,
java.lang.Object[] params,
java.lang.String stmtId)
This is for preprocessor-generated QueryPieces (see Query ). |
|
java.sql.Statement |
createStatement()
Creates Statement. |
|
void |
endCall(java.sql.CallableStatement stmt)
Closes CallableStatement. |
|
void |
executeCall(java.sql.CallableStatement stmt)
Executes stored procedure or PL/SQL block. |
|
java.lang.Object[] |
executeCall(QueryPiece query)
Executes PL/SQL block constructed from pieces. |
|
java.lang.Object[] |
executeCall(java.lang.String sql,
java.lang.Object... params)
Executes CallableStatement. |
|
java.lang.Object[] |
executeCall(java.lang.String sql,
java.lang.Object[] params,
java.lang.Class<?>[] paramTypes)
This is for preprocessor-generated CallableStatements. |
|
java.lang.Object[] |
executeCall(java.lang.String sql,
java.lang.Object[] params,
java.lang.String stmtId)
This is for preprocessor-generated CallableStatements. |
|
void |
executeSql(java.lang.String sql)
Executes SQL statement. |
|
int |
executeUpdate(java.sql.PreparedStatement stmt)
Executes update/delete/insert SQL statement. |
|
int |
executeUpdate(java.sql.PreparedStatement stmt,
boolean reuse)
Same as executeUpdate(java.sql.PreparedStatement) but closes statement when reuse=false . |
|
static java.math.BigDecimal |
getBigDecimal(java.sql.CallableStatement stmt,
int i)
Returns OUT parameter of stored procedure with index i (from 1) as BigDecimal . |
|
static byte[] |
getBytes(java.sql.CallableStatement stmt,
int i)
Returns OUT parameter of stored procedure with index i (from 1) as byte[] . |
|
static java.sql.Date |
getDate(java.sql.CallableStatement stmt,
int i)
Returns OUT parameter of stored procedure with index i (from 1) as Date . |
|
static java.lang.Double |
getDouble(java.sql.CallableStatement stmt,
int i)
Returns OUT parameter of stored procedure with index i (from 1) as Double . |
|
java.lang.Number[] |
getGeneratedKeys(java.sql.PreparedStatement stmt)
Returns array of auto-generated keys for insert/update statement. |
|
static java.lang.Integer |
getInt(java.sql.CallableStatement stmt,
int i)
Returns OUT parameter of stored procedure with index i (from 1) as Integer . |
|
|
getInterface(java.lang.Class<T> iface)
Returns data access interface generated by preprocessor. |
|
protected java.sql.Connection |
getJdbcConnection()
Access to raw JDBC connection. |
|
static java.lang.Long |
getLong(java.sql.CallableStatement stmt,
int i)
Returns OUT parameter of stored procedure with index i (from 1) as Long . |
|
long |
getNextId(java.lang.String sequence)
Returns next number in sequence. |
|
static java.lang.Object |
getObject(java.sql.CallableStatement stmt,
int i)
Returns OUT parameter of stored procedure with index i (from 1) as Object . |
|
static java.lang.String |
getString(java.sql.CallableStatement stmt,
int i)
Returns OUT parameter of stored procedure with index i (from 1) as String . |
|
static java.sql.Time |
getTime(java.sql.CallableStatement stmt,
int i)
Returns OUT parameter of stored procedure with index i (from 1) as Time . |
|
static java.sql.Timestamp |
getTimestamp(java.sql.CallableStatement stmt,
int i)
Returns OUT parameter of stored procedure with index i (from 1) as Timestamp . |
|
static boolean |
isTesting()
Returns true if method is called at preprocessing time (false at application run time). |
|
|
metaRowQuery(java.sql.PreparedStatement stmt,
java.lang.Class<T> cls)
Returns result set metadata as RowType object. |
|
|
multiRowQuery(java.sql.PreparedStatement stmt,
java.lang.Class<T> cls)
Executes select query returning multiple (zero or more) rows. |
|
|
newRow(java.lang.Class<T> cls)
Create row instance by row type class; class should have EditableRowType annotation. |
|
|
optionalRowQuery(java.sql.PreparedStatement stmt,
java.lang.Class<T> cls)
Same as singleRowQuery(java.sql.PreparedStatement, Class) but returns
null when no rows found. |
|
|
optionalRowQueryReturning(java.lang.Class<T> cls,
java.sql.PreparedStatement stmt)
Same as singleRowQueryReturning(Class, java.sql.PreparedStatement) but returns
null when no rows found. |
|
java.math.BigDecimal |
optionalRowQueryReturningBigDecimal(java.sql.PreparedStatement stmt)
Same as singleRowQueryReturningBigDecimal(java.sql.PreparedStatement) but returns
null when no rows found. |
|
byte[] |
optionalRowQueryReturningBlob(java.sql.PreparedStatement stmt)
Same as singleRowQueryReturningBlob(java.sql.PreparedStatement) but returns
null when no rows found. |
|
byte[] |
optionalRowQueryReturningBytes(java.sql.PreparedStatement stmt)
Same as singleRowQueryReturningBytes(java.sql.PreparedStatement) but returns
null when no rows found. |
|
java.lang.String |
optionalRowQueryReturningClob(java.sql.PreparedStatement stmt)
Same as singleRowQueryReturningClob(java.sql.PreparedStatement) but returns
null when no rows found. |
|
java.sql.Date |
optionalRowQueryReturningDate(java.sql.PreparedStatement stmt)
Same as singleRowQueryReturningDate(java.sql.PreparedStatement) but returns
null when no rows found. |
|
java.lang.Double |
optionalRowQueryReturningDouble(java.sql.PreparedStatement stmt)
Same as singleRowQueryReturningDouble(java.sql.PreparedStatement) but returns
null when no rows found. |
|
java.lang.Integer |
optionalRowQueryReturningInt(java.sql.PreparedStatement stmt)
Same as singleRowQueryReturningInt(java.sql.PreparedStatement) but returns
null when no rows found. |
|
java.lang.Long |
optionalRowQueryReturningLong(java.sql.PreparedStatement stmt)
Same as singleRowQueryReturningLong(java.sql.PreparedStatement) but returns
null when no rows found. |
|
java.lang.Object |
optionalRowQueryReturningObject(java.sql.PreparedStatement stmt)
Same as singleRowQueryReturningObject(java.sql.PreparedStatement) but returns
null when no rows found. |
|
java.lang.String |
optionalRowQueryReturningString(java.sql.PreparedStatement stmt)
Same as singleRowQueryReturningString(java.sql.PreparedStatement) but returns
null when no rows found. |
|
java.sql.Time |
optionalRowQueryReturningTime(java.sql.PreparedStatement stmt)
Same as singleRowQueryReturningTime(java.sql.PreparedStatement) but returns
null when no rows found. |
|
java.sql.Timestamp |
optionalRowQueryReturningTimestamp(java.sql.PreparedStatement stmt)
Same as singleRowQueryReturningTimestamp(java.sql.PreparedStatement) but returns
null when no rows found. |
|
OutParameter |
out(java.lang.Object param)
This is for preprocessor-generated CallableStatements. |
|
static
|
outResultSet(java.lang.Class<T> cls)
Creates OUT parameter for cursor parameters. |
|
java.sql.CallableStatement |
prepareCall(java.lang.String sql)
Creates CallableStatement for stored procedure (or PL/SQL block) call. |
|
java.sql.PreparedStatement |
prepareStatement(QueryPiece query)
Creates PreparedStatement for further execution. |
|
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql)
Creates PreparedStatement for further execution. |
|
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql,
java.lang.Object... params)
Creates PreparedStatement for further execution. |
|
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql,
java.lang.Object[] params,
java.lang.Class<?>[] paramTypes)
This is for preprocessor-generated PreparedStatements (see Prepare ). |
|
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql,
java.lang.Object[] params,
java.lang.String stmtId)
This is for preprocessor-generated PreparedStatements (see Prepare ). |
|
java.sql.PreparedStatement |
prepareStatementKey(java.lang.String[] autoKeys,
QueryPiece query)
Creates PreparedStatement with auto-generated keys for further execution. |
|
java.sql.PreparedStatement |
prepareStatementKey(java.lang.String[] autoKeys,
java.lang.String sql)
Creates PreparedStatement with auto-generated keys for further execution. |
|
java.sql.PreparedStatement |
prepareStatementKey(java.lang.String[] autoKeys,
java.lang.String sql,
java.lang.Object... params)
Creates PreparedStatement with auto-generated keys for further execution. |
|
java.sql.PreparedStatement |
prepareStatementKey(java.lang.String[] autoKeys,
java.lang.String sql,
java.lang.Object[] params,
java.lang.Class<?>[] paramTypes)
This is for preprocessor-generated PreparedStatements with auto-generated keys (see PrepareKey ). |
|
java.sql.PreparedStatement |
prepareStatementKey(java.lang.String[] autoKeys,
java.lang.String sql,
java.lang.Object[] params,
java.lang.String stmtId)
This is for preprocessor-generated PreparedStatements with auto-generated keys (see PrepareKey ). |
|
void |
setBlob(java.sql.PreparedStatement stmt,
byte[] data)
Writes bytes to BLOB. |
|
void |
setClob(java.sql.PreparedStatement stmt,
java.lang.String text)
Writes text to CLOB. |
|
void |
setParameter(java.sql.PreparedStatement st,
int index,
java.lang.Object param)
|
|
void |
setParameter(java.sql.PreparedStatement st,
int index,
java.lang.Object param,
java.lang.Class<?> cls)
|
|
void |
setParameters(java.sql.PreparedStatement st,
java.lang.Object... in)
Binds prepared statement parameters to specific values. |
|
|
singleRowQuery(java.sql.PreparedStatement stmt,
java.lang.Class<T> cls)
Executes select query, which should return one row (more or less than one rows raises runtime exception). |
|
|
singleRowQueryReturning(java.lang.Class<T> cls,
java.sql.PreparedStatement stmt)
Executes select query, which should return one row and one column (more or less than one rows raises runtime exception, more or less than one column raises preprocess-time exception). |
|
java.math.BigDecimal |
singleRowQueryReturningBigDecimal(java.sql.PreparedStatement stmt)
Executes select query, which should return one row and one column (more or less than one rows raises runtime exception, more or less than one column raises preprocess-time exception). |
|
byte[] |
singleRowQueryReturningBlob(java.sql.PreparedStatement stmt)
Executes select query, which should return one row and one column (more or less than one rows raises runtime exception, more or less than one column raises preprocess-time exception). |
|
byte[] |
singleRowQueryReturningBytes(java.sql.PreparedStatement stmt)
Executes select query, which should return one row and one column (more or less than one rows raises runtime exception, more or less than one column raises preprocess-time exception). |
|
java.lang.String |
singleRowQueryReturningClob(java.sql.PreparedStatement stmt)
Executes select query, which should return one row and one column (more or less than one rows raises runtime exception, more or less than one column raises preprocess-time exception). |
|
java.sql.Date |
singleRowQueryReturningDate(java.sql.PreparedStatement stmt)
Executes select query, which should return one row and one column (more or less than one rows raises runtime exception, more or less than one column raises preprocess-time exception). |
|
double |
singleRowQueryReturningDouble(java.sql.PreparedStatement stmt)
Executes select query, which should return one row and one column (more or less than one rows raises runtime exception, more or less than one column raises preprocess-time exception). |
|
java.lang.Double |
singleRowQueryReturningDOUBLE(java.sql.PreparedStatement stmt)
Executes select query, which should return one row and one column (more or less than one rows raises runtime exception, more or less than one column raises preprocess-time exception). |
|
int |
singleRowQueryReturningInt(java.sql.PreparedStatement stmt)
Executes select query, which should return one row and one column (more or less than one rows raises runtime exception, more or less than one column raises preprocess-time exception). |
|
java.lang.Integer |
singleRowQueryReturningINT(java.sql.PreparedStatement stmt)
Executes select query, which should return one row and one column (more or less than one rows raises runtime exception, more or less than one column raises preprocess-time exception). |
|
long |
singleRowQueryReturningLong(java.sql.PreparedStatement stmt)
Executes select query, which should return one row and one column (more or less than one rows raises runtime exception, more or less than one column raises preprocess-time exception). |
|
java.lang.Long |
singleRowQueryReturningLONG(java.sql.PreparedStatement stmt)
Executes select query, which should return one row and one column (more or less than one rows raises runtime exception, more or less than one column raises preprocess-time exception). |
|
java.lang.Object |
singleRowQueryReturningObject(java.sql.PreparedStatement stmt)
Executes select query, which should return one row and one column (more or less than one rows raises runtime exception, more or less than one column raises preprocess-time exception). |
|
java.lang.String |
singleRowQueryReturningString(java.sql.PreparedStatement stmt)
Executes select query, which should return one row and one column (more or less than one rows raises runtime exception, more or less than one column raises preprocess-time exception). |
|
java.sql.Time |
singleRowQueryReturningTime(java.sql.PreparedStatement stmt)
Executes select query, which should return one row and one column (more or less than one rows raises runtime exception, more or less than one column raises preprocess-time exception). |
|
java.sql.Timestamp |
singleRowQueryReturningTimestamp(java.sql.PreparedStatement stmt)
Executes select query, which should return one row and one column (more or less than one rows raises runtime exception, more or less than one column raises preprocess-time exception). |
|
void |
traceSql(boolean ok)
SQL tracing. |
|
void |
traceSql(boolean ok,
long t0)
SQL tracing. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String[] ALL_KEYS
autoKeys
parameter of prepareStatementKey(String[], String)
to
retrieve all generated columns.
PrepareKey.value()
Constructor Detail |
---|
public GBase(LocalWrapperBase lwb)
lwb
- wrapper for this objectMethod Detail |
---|
public static boolean isTesting()
protected final java.sql.Connection getJdbcConnection() throws java.sql.SQLException
isTesting()
before calling this method.
java.sql.SQLException
public final void traceSql(boolean ok)
ok
- false if SQL caused an errorpublic final void traceSql(boolean ok, long t0)
ok
- false if SQL caused an errort0
- business method start time (as in System.currentTimeMillis()
public final void executeSql(java.lang.String sql) throws java.sql.SQLException
Warning: usually you should call this method only at application run time, not at
preprocess time, because it can alter DB state (for example, when you execute DROP TABLE
statement). Since preprocessor executes business method code and it is undesirable for preprocessor
to alter DB state, calls to this method should be guarded by check of isTesting()
:
if (isTesting()) { executeSql("DROP TABLE BOBBY"); }
sql
- SQL statement to execute
java.sql.SQLException
public final java.sql.Statement createStatement() throws java.sql.SQLException
Warning: usually you should call this method only at application run time, not at
preprocess time, because it can alter DB state (for example, when you execute DROP TABLE
statement). Since preprocessor executes business method code and it is undesirable for preprocessor
to alter DB state, calls to this method should be guarded by check of isTesting()
:
if (isTesting()) { Statement st = createStatement(); st.execute("DROP TABLE BOBBY"); }
java.sql.SQLException
public static QueryPiece createQueryPiece(java.lang.String sql)
sql
- SQL textpublic static QueryPiece createQueryPiece(QueryPiece query)
Query
).
public static QueryPiece createQueryPiece(java.lang.String sql, java.lang.Object[] params, java.lang.Class<?>[] paramTypes)
Query
).
public static QueryPiece createQueryPiece(java.lang.String sql, java.lang.Object[] params, java.lang.String stmtId)
Query
).
public final java.sql.PreparedStatement prepareStatement(java.lang.String sql) throws java.sql.SQLException
executeUpdate(java.sql.PreparedStatement)
or by some select method.
It is more convenient to use Prepare
annotation to generate such queries than
to use this method manually.
java.sql.SQLException
public final java.sql.PreparedStatement prepareStatementKey(java.lang.String[] autoKeys, java.lang.String sql) throws java.sql.SQLException
executeUpdate(java.sql.PreparedStatement, boolean)
and generated
keys extracted with getGeneratedKeys(java.sql.PreparedStatement)
.
It is more convenient to use PrepareKey
annotation to generate such queries than
to use this method manually.
autoKeys
- array of column names which are auto-generated. Note that upper/lower case may be significant
(depends on DB).
java.sql.SQLException
public final java.sql.PreparedStatement prepareStatement(java.lang.String sql, java.lang.Object[] params, java.lang.Class<?>[] paramTypes) throws java.sql.SQLException
Prepare
).
Creates PreparedStatement for further execution.
java.sql.SQLException
public final java.sql.PreparedStatement prepareStatementKey(java.lang.String[] autoKeys, java.lang.String sql, java.lang.Object[] params, java.lang.Class<?>[] paramTypes) throws java.sql.SQLException
PrepareKey
).
Creates PreparedStatement for further execution.
java.sql.SQLException
public final java.sql.PreparedStatement prepareStatement(QueryPiece query) throws java.sql.SQLException
executeUpdate(java.sql.PreparedStatement)
or by some select method.
java.sql.SQLException
public final java.sql.PreparedStatement prepareStatementKey(java.lang.String[] autoKeys, QueryPiece query) throws java.sql.SQLException
executeUpdate(java.sql.PreparedStatement, boolean)
and generated
keys extracted with getGeneratedKeys(java.sql.PreparedStatement)
.
autoKeys
- array of column names which are auto-generated. Note that upper/lower case may be significant
(depends on DB).
java.sql.SQLException
public final java.sql.PreparedStatement prepareStatement(java.lang.String sql, java.lang.Object[] params, java.lang.String stmtId) throws java.sql.SQLException
Prepare
).
Creates PreparedStatement for further execution.
java.sql.SQLException
public final java.sql.PreparedStatement prepareStatementKey(java.lang.String[] autoKeys, java.lang.String sql, java.lang.Object[] params, java.lang.String stmtId) throws java.sql.SQLException
PrepareKey
).
Creates PreparedStatement for further execution.
java.sql.SQLException
public final java.sql.PreparedStatement prepareStatement(java.lang.String sql, java.lang.Object... params) throws java.sql.SQLException
executeUpdate(java.sql.PreparedStatement)
or by some select method.
It is more convenient to use Prepare
annotation to generate such queries than
to use this method manually.
params
- parameters for PreparedStatement.setXXX
java.sql.SQLException
public final java.sql.PreparedStatement prepareStatementKey(java.lang.String[] autoKeys, java.lang.String sql, java.lang.Object... params) throws java.sql.SQLException
executeUpdate(java.sql.PreparedStatement, boolean)
and generated
keys extracted with getGeneratedKeys(java.sql.PreparedStatement)
.
It is more convenient to use PrepareKey
annotation to generate such queries than
to use this method manually.
autoKeys
- array of column names which are auto-generated. Note that upper/lower case may be significant
(depends on DB).params
- parameters for PreparedStatement.setXXX
java.sql.SQLException
public final java.sql.CallableStatement prepareCall(java.lang.String sql) throws java.sql.SQLException
sql
- stored procedure to call.
Syntax is the same as for Connection.prepareCall(String)
:
java.sql.SQLException
public final OutParameter out(java.lang.Object param)
param
- Shoud be an array with at least one element to store output valuepublic static <T> TypedList<T> outResultSet(java.lang.Class<T> cls)
cls
- row type class to be returned from cursorpublic final java.lang.Object[] executeCall(QueryPiece query) throws java.sql.SQLException
query
- query text and parameter values
java.sql.SQLException
public final java.lang.Object[] executeCall(java.lang.String sql, java.lang.Object[] params, java.lang.Class<?>[] paramTypes) throws java.sql.SQLException
java.sql.SQLException
public final java.lang.Object[] executeCall(java.lang.String sql, java.lang.Object[] params, java.lang.String stmtId) throws java.sql.SQLException
java.sql.SQLException
public final java.lang.Object[] executeCall(java.lang.String sql, java.lang.Object... params) throws java.sql.SQLException
params
- parameters for CallableStatement.setXXX. Can contain OutParameter
.
java.sql.SQLException
public final <T> T newRow(java.lang.Class<T> cls)
EditableRowType
annotation.
Returns null
executeUpdate
public final int executeUpdate(java.sql.PreparedStatement stmt)
throws java.sql.SQLException
- Executes update/delete/insert SQL statement. This method should always be used
instead of
PreparedStatement.executeUpdate()
because the latter can modify
database state at preprocess phase.
This method does not close statement, so it can be called multiple times.
You don't have to close statement manually if it was created with prepareStatement(String)
or the like,
because all statements created with GBase
methods are closed automatically after business method exit.
- Parameters:
stmt
- SQL statement
- Returns:
- number of modified database rows
- Throws:
java.sql.SQLException
executeUpdate
public final int executeUpdate(java.sql.PreparedStatement stmt,
boolean reuse)
throws java.sql.SQLException
- Same as
executeUpdate(java.sql.PreparedStatement)
but closes statement when reuse=false
.
- Parameters:
stmt
- SQL statementreuse
- false if close statement after execution
- Returns:
- number of modified database rows
- Throws:
java.sql.SQLException
getGeneratedKeys
public final java.lang.Number[] getGeneratedKeys(java.sql.PreparedStatement stmt)
throws java.sql.SQLException
- Returns array of auto-generated keys for insert/update statement. List of auto-generated
columns is provided by
prepareStatementKey(String[], sqlg2.db.QueryPiece)
autoKeys
parameter or by PrepareKey
annotation value. Number of elements in array equals to the number
of auto-generated columns.
- Throws:
java.sql.SQLException
executeCall
public final void executeCall(java.sql.CallableStatement stmt)
throws java.sql.SQLException
- Executes stored procedure or PL/SQL block.
Does not close statement, you can explicitly call
endCall(java.sql.CallableStatement)
to close it.
You can retrieve OUT parameters with getXXX(CallableStatement, int)
methods after call to this method.
- Throws:
java.sql.SQLException
endCall
public final void endCall(java.sql.CallableStatement stmt)
- Closes CallableStatement.
getInt
public static java.lang.Integer getInt(java.sql.CallableStatement stmt,
int i)
throws java.sql.SQLException
- Returns OUT parameter of stored procedure with index i (from 1) as
Integer
.
- Throws:
java.sql.SQLException
getLong
public static java.lang.Long getLong(java.sql.CallableStatement stmt,
int i)
throws java.sql.SQLException
- Returns OUT parameter of stored procedure with index i (from 1) as
Long
.
- Throws:
java.sql.SQLException
getDouble
public static java.lang.Double getDouble(java.sql.CallableStatement stmt,
int i)
throws java.sql.SQLException
- Returns OUT parameter of stored procedure with index i (from 1) as
Double
.
- Throws:
java.sql.SQLException
getString
public static java.lang.String getString(java.sql.CallableStatement stmt,
int i)
throws java.sql.SQLException
- Returns OUT parameter of stored procedure with index i (from 1) as
String
.
- Throws:
java.sql.SQLException
getBytes
public static byte[] getBytes(java.sql.CallableStatement stmt,
int i)
throws java.sql.SQLException
- Returns OUT parameter of stored procedure with index i (from 1) as
byte[]
.
- Throws:
java.sql.SQLException
getBigDecimal
public static java.math.BigDecimal getBigDecimal(java.sql.CallableStatement stmt,
int i)
throws java.sql.SQLException
- Returns OUT parameter of stored procedure with index i (from 1) as
BigDecimal
.
- Throws:
java.sql.SQLException
getDate
public static java.sql.Date getDate(java.sql.CallableStatement stmt,
int i)
throws java.sql.SQLException
- Returns OUT parameter of stored procedure with index i (from 1) as
Date
.
- Throws:
java.sql.SQLException
getTime
public static java.sql.Time getTime(java.sql.CallableStatement stmt,
int i)
throws java.sql.SQLException
- Returns OUT parameter of stored procedure with index i (from 1) as
Time
.
- Throws:
java.sql.SQLException
getTimestamp
public static java.sql.Timestamp getTimestamp(java.sql.CallableStatement stmt,
int i)
throws java.sql.SQLException
- Returns OUT parameter of stored procedure with index i (from 1) as
Timestamp
.
- Throws:
java.sql.SQLException
getObject
public static java.lang.Object getObject(java.sql.CallableStatement stmt,
int i)
throws java.sql.SQLException
- Returns OUT parameter of stored procedure with index i (from 1) as
Object
.
- Throws:
java.sql.SQLException
singleRowQueryReturningInt
public final int singleRowQueryReturningInt(java.sql.PreparedStatement stmt)
throws java.sql.SQLException
- Executes select query, which should return one row and one column (more or less than
one rows raises runtime exception, more or less than one column raises
preprocess-time exception). Result is returned as a single
int
.
Closes statement after execution.
- Throws:
java.sql.SQLException
singleRowQueryReturningLong
public final long singleRowQueryReturningLong(java.sql.PreparedStatement stmt)
throws java.sql.SQLException
- Executes select query, which should return one row and one column (more or less than
one rows raises runtime exception, more or less than one column raises
preprocess-time exception). Result is returned as a single
long
.
Closes statement after execution.
- Throws:
java.sql.SQLException
singleRowQueryReturningDouble
public final double singleRowQueryReturningDouble(java.sql.PreparedStatement stmt)
throws java.sql.SQLException
- Executes select query, which should return one row and one column (more or less than
one rows raises runtime exception, more or less than one column raises
preprocess-time exception). Result is returned as a single
double
.
Closes statement after execution.
- Throws:
java.sql.SQLException
singleRowQueryReturningINT
public final java.lang.Integer singleRowQueryReturningINT(java.sql.PreparedStatement stmt)
throws java.sql.SQLException
- Executes select query, which should return one row and one column (more or less than
one rows raises runtime exception, more or less than one column raises
preprocess-time exception). Result is returned as a single
Integer
.
Closes statement after execution.
- Throws:
java.sql.SQLException
singleRowQueryReturningLONG
public final java.lang.Long singleRowQueryReturningLONG(java.sql.PreparedStatement stmt)
throws java.sql.SQLException
- Executes select query, which should return one row and one column (more or less than
one rows raises runtime exception, more or less than one column raises
preprocess-time exception). Result is returned as a single
Long
.
Closes statement after execution.
- Throws:
java.sql.SQLException
singleRowQueryReturningDOUBLE
public final java.lang.Double singleRowQueryReturningDOUBLE(java.sql.PreparedStatement stmt)
throws java.sql.SQLException
- Executes select query, which should return one row and one column (more or less than
one rows raises runtime exception, more or less than one column raises
preprocess-time exception). Result is returned as a single
Double
.
Closes statement after execution.
- Throws:
java.sql.SQLException
singleRowQueryReturningString
public final java.lang.String singleRowQueryReturningString(java.sql.PreparedStatement stmt)
throws java.sql.SQLException
- Executes select query, which should return one row and one column (more or less than
one rows raises runtime exception, more or less than one column raises
preprocess-time exception). Result is returned as a single
String
.
Closes statement after execution.
- Throws:
java.sql.SQLException
singleRowQueryReturningBytes
public final byte[] singleRowQueryReturningBytes(java.sql.PreparedStatement stmt)
throws java.sql.SQLException
- Executes select query, which should return one row and one column (more or less than
one rows raises runtime exception, more or less than one column raises
preprocess-time exception). Result is returned as a single
byte[]
.
Closes statement after execution.
- Throws:
java.sql.SQLException
singleRowQueryReturningBigDecimal
public final java.math.BigDecimal singleRowQueryReturningBigDecimal(java.sql.PreparedStatement stmt)
throws java.sql.SQLException
- Executes select query, which should return one row and one column (more or less than
one rows raises runtime exception, more or less than one column raises
preprocess-time exception). Result is returned as a single
BigDecimal
.
Closes statement after execution.
- Throws:
java.sql.SQLException
singleRowQueryReturningDate
public final java.sql.Date singleRowQueryReturningDate(java.sql.PreparedStatement stmt)
throws java.sql.SQLException
- Executes select query, which should return one row and one column (more or less than
one rows raises runtime exception, more or less than one column raises
preprocess-time exception). Result is returned as a single
Date
.
Closes statement after execution.
- Throws:
java.sql.SQLException
singleRowQueryReturningTime
public final java.sql.Time singleRowQueryReturningTime(java.sql.PreparedStatement stmt)
throws java.sql.SQLException
- Executes select query, which should return one row and one column (more or less than
one rows raises runtime exception, more or less than one column raises
preprocess-time exception). Result is returned as a single
Time
.
Closes statement after execution.
- Throws:
java.sql.SQLException
singleRowQueryReturningTimestamp
public final java.sql.Timestamp singleRowQueryReturningTimestamp(java.sql.PreparedStatement stmt)
throws java.sql.SQLException
- Executes select query, which should return one row and one column (more or less than
one rows raises runtime exception, more or less than one column raises
preprocess-time exception). Result is returned as a single
Timestamp
.
Closes statement after execution.
- Throws:
java.sql.SQLException
singleRowQueryReturningObject
public final java.lang.Object singleRowQueryReturningObject(java.sql.PreparedStatement stmt)
throws java.sql.SQLException
- Executes select query, which should return one row and one column (more or less than
one rows raises runtime exception, more or less than one column raises
preprocess-time exception). Result is returned as a single
Object
.
Closes statement after execution.
- Throws:
java.sql.SQLException
singleRowQueryReturningClob
public final java.lang.String singleRowQueryReturningClob(java.sql.PreparedStatement stmt)
throws java.sql.SQLException
- Executes select query, which should return one row and one column (more or less than
one rows raises runtime exception, more or less than one column raises
preprocess-time exception). Result is returned as a single
String
.
Closes statement after execution.
- Throws:
java.sql.SQLException
singleRowQueryReturningBlob
public final byte[] singleRowQueryReturningBlob(java.sql.PreparedStatement stmt)
throws java.sql.SQLException
- Executes select query, which should return one row and one column (more or less than
one rows raises runtime exception, more or less than one column raises
preprocess-time exception). Result is returned as a single
byte[]
.
Closes statement after execution.
- Throws:
java.sql.SQLException
singleRowQueryReturning
public final <T extends MappedType> T singleRowQueryReturning(java.lang.Class<T> cls,
java.sql.PreparedStatement stmt)
throws java.sql.SQLException
- Executes select query, which should return one row and one column (more or less than
one rows raises runtime exception, more or less than one column raises
preprocess-time exception).
Closes statement after execution.
- Parameters:
cls
- class with user-defined mapping
- Throws:
java.sql.SQLException
optionalRowQueryReturningInt
public final java.lang.Integer optionalRowQueryReturningInt(java.sql.PreparedStatement stmt)
throws java.sql.SQLException
- Same as
singleRowQueryReturningInt(java.sql.PreparedStatement)
but returns
null when no rows found.
Closes statement after execution.
- Throws:
java.sql.SQLException
optionalRowQueryReturningLong
public final java.lang.Long optionalRowQueryReturningLong(java.sql.PreparedStatement stmt)
throws java.sql.SQLException
- Same as
singleRowQueryReturningLong(java.sql.PreparedStatement)
but returns
null when no rows found.
Closes statement after execution.
- Throws:
java.sql.SQLException
optionalRowQueryReturningDouble
public final java.lang.Double optionalRowQueryReturningDouble(java.sql.PreparedStatement stmt)
throws java.sql.SQLException
- Same as
singleRowQueryReturningDouble(java.sql.PreparedStatement)
but returns
null when no rows found.
Closes statement after execution.
- Throws:
java.sql.SQLException
optionalRowQueryReturningString
public final java.lang.String optionalRowQueryReturningString(java.sql.PreparedStatement stmt)
throws java.sql.SQLException
- Same as
singleRowQueryReturningString(java.sql.PreparedStatement)
but returns
null when no rows found.
Closes statement after execution.
- Throws:
java.sql.SQLException
optionalRowQueryReturningBytes
public final byte[] optionalRowQueryReturningBytes(java.sql.PreparedStatement stmt)
throws java.sql.SQLException
- Same as
singleRowQueryReturningBytes(java.sql.PreparedStatement)
but returns
null when no rows found.
Closes statement after execution.
- Throws:
java.sql.SQLException
optionalRowQueryReturningBigDecimal
public final java.math.BigDecimal optionalRowQueryReturningBigDecimal(java.sql.PreparedStatement stmt)
throws java.sql.SQLException
- Same as
singleRowQueryReturningBigDecimal(java.sql.PreparedStatement)
but returns
null when no rows found.
Closes statement after execution.
- Throws:
java.sql.SQLException
optionalRowQueryReturningDate
public final java.sql.Date optionalRowQueryReturningDate(java.sql.PreparedStatement stmt)
throws java.sql.SQLException
- Same as
singleRowQueryReturningDate(java.sql.PreparedStatement)
but returns
null when no rows found.
Closes statement after execution.
- Throws:
java.sql.SQLException
optionalRowQueryReturningTime
public final java.sql.Time optionalRowQueryReturningTime(java.sql.PreparedStatement stmt)
throws java.sql.SQLException
- Same as
singleRowQueryReturningTime(java.sql.PreparedStatement)
but returns
null when no rows found.
Closes statement after execution.
- Throws:
java.sql.SQLException
optionalRowQueryReturningTimestamp
public final java.sql.Timestamp optionalRowQueryReturningTimestamp(java.sql.PreparedStatement stmt)
throws java.sql.SQLException
- Same as
singleRowQueryReturningTimestamp(java.sql.PreparedStatement)
but returns
null when no rows found.
Closes statement after execution.
- Throws:
java.sql.SQLException
optionalRowQueryReturningClob
public final java.lang.String optionalRowQueryReturningClob(java.sql.PreparedStatement stmt)
throws java.sql.SQLException
- Same as
singleRowQueryReturningClob(java.sql.PreparedStatement)
but returns
null when no rows found.
Closes statement after execution.
- Throws:
java.sql.SQLException
optionalRowQueryReturningBlob
public final byte[] optionalRowQueryReturningBlob(java.sql.PreparedStatement stmt)
throws java.sql.SQLException
- Same as
singleRowQueryReturningBlob(java.sql.PreparedStatement)
but returns
null when no rows found.
Closes statement after execution.
- Throws:
java.sql.SQLException
optionalRowQueryReturningObject
public final java.lang.Object optionalRowQueryReturningObject(java.sql.PreparedStatement stmt)
throws java.sql.SQLException
- Same as
singleRowQueryReturningObject(java.sql.PreparedStatement)
but returns
null when no rows found.
Closes statement after execution.
- Throws:
java.sql.SQLException
optionalRowQueryReturning
public final <T extends MappedType> T optionalRowQueryReturning(java.lang.Class<T> cls,
java.sql.PreparedStatement stmt)
throws java.sql.SQLException
- Same as
singleRowQueryReturning(Class, java.sql.PreparedStatement)
but returns
null when no rows found.
Closes statement after execution.
- Parameters:
cls
- class with user-defined mapping
- Throws:
java.sql.SQLException
columnOfInt
public final int[] columnOfInt(java.sql.PreparedStatement stmt)
throws java.sql.SQLException
- Executes select query returning single column of
int
.
Closes statement after execution.
- Throws:
java.sql.SQLException
columnOfLong
public final long[] columnOfLong(java.sql.PreparedStatement stmt)
throws java.sql.SQLException
- Executes select query returning single column of
long
.
Closes statement after execution.
- Throws:
java.sql.SQLException
columnOfDouble
public final double[] columnOfDouble(java.sql.PreparedStatement stmt)
throws java.sql.SQLException
- Executes select query returning single column of
double
.
Closes statement after execution.
- Throws:
java.sql.SQLException
columnOfString
public final java.lang.String[] columnOfString(java.sql.PreparedStatement stmt)
throws java.sql.SQLException
- Executes select query returning single column of
String
.
Closes statement after execution.
- Throws:
java.sql.SQLException
columnOfObject
public final java.lang.Object[] columnOfObject(java.sql.PreparedStatement stmt)
throws java.sql.SQLException
- Executes select query returning single column of
Object
.
Closes statement after execution.
- Throws:
java.sql.SQLException
columnOf
public final <T extends MappedType> java.util.List<T> columnOf(java.lang.Class<T> cls,
java.sql.PreparedStatement stmt)
throws java.sql.SQLException
- Executes select query returning single column of T.
Closes statement after execution.
- Parameters:
cls
- class with user-defined mapping
- Throws:
java.sql.SQLException
singleRowQuery
public final <T> T singleRowQuery(java.sql.PreparedStatement stmt,
java.lang.Class<T> cls)
throws java.sql.SQLException
- Executes select query, which should return one row (more or less than
one rows raises runtime exception).
Result is returned as an object which class implementation is generated by preprocessor.
Closes statement after execution.
- Parameters:
stmt
- SQL statementcls
- row type class or interface generated by preprocessor (see RowType
).
- Throws:
java.sql.SQLException
optionalRowQuery
public final <T> T optionalRowQuery(java.sql.PreparedStatement stmt,
java.lang.Class<T> cls)
throws java.sql.SQLException
- Same as
singleRowQuery(java.sql.PreparedStatement, Class)
but returns
null when no rows found.
Closes statement after execution.
- Throws:
java.sql.SQLException
multiRowQuery
public final <T> java.util.List<T> multiRowQuery(java.sql.PreparedStatement stmt,
java.lang.Class<T> cls)
throws java.sql.SQLException
- Executes select query returning multiple (zero or more) rows.
Result is returned as a list of objects which class implementation is generated by preprocessor.
Closes statement after execution.
- Parameters:
stmt
- SQL statementcls
- row type class or interface generated by preprocessor (see RowType
).
- Throws:
java.sql.SQLException
metaRowQuery
public final <T> T metaRowQuery(java.sql.PreparedStatement stmt,
java.lang.Class<T> cls)
throws java.sql.SQLException
- Returns result set metadata as RowType object. Columns of RowType contain:
- For integer types (byte, short, int, long) field contains column's max length
- For character types (String) field contains string of max length (containing only '\0' chars)
- For RAW types (byte[]) field contains byte array of max length (containing only zero bytes)
- For other types field contains 0/null/false.
- Throws:
java.sql.SQLException
close
public final void close(java.sql.Statement st)
- Closes statement.
close
public final void close(java.sql.ResultSet rs,
java.sql.Statement st)
- Closes result set and statement.
closeStatements
public final void closeStatements()
- Closes all open statements (usually this method is called by wrappers automatically).
setClob
public final void setClob(java.sql.PreparedStatement stmt,
java.lang.String text)
throws java.sql.SQLException
- Writes text to CLOB. Statement should contain
SELECT … FOR UPDATE
SQL statement.
This method does NOT write EMPTY_CLOB
before writing data, so you should
do it yourself if required.
Closes statement after execution.
- Parameters:
stmt
- SELECT … FOR UPDATE
SQL statementtext
- text to write
- Throws:
java.sql.SQLException
setBlob
public final void setBlob(java.sql.PreparedStatement stmt,
byte[] data)
throws java.sql.SQLException
- Writes bytes to BLOB. Statement should contain
SELECT … FOR UPDATE
SQL statement.
This method does NOT write EMPTY_BLOB
before writing data, so you should
do it yourself if required.
Closes statement after execution.
- Parameters:
stmt
- SELECT … FOR UPDATE
SQL statementdata
- bytes to write
- Throws:
java.sql.SQLException
getNextId
public final long getNextId(java.lang.String sequence)
throws java.sql.SQLException
- Returns next number in sequence.
- Parameters:
sequence
- sequence name
- Throws:
java.sql.SQLException
setParameters
public final void setParameters(java.sql.PreparedStatement st,
java.lang.Object... in)
throws java.sql.SQLException
- Binds prepared statement parameters to specific values.
Allowed object types: Byte, Short, Integer, Long, Float,
Double, String, StringBuilder, Boolean, Character, Date, byte[],
MappedType
.
Effect is the same as for
setParameter(st, 1, in[0]);
...
setParameter(st, n, in[n - 1]);
- Parameters:
st
- SQL statementin
- parameter values
- Throws:
java.sql.SQLException
setParameter
public final void setParameter(java.sql.PreparedStatement st,
int index,
java.lang.Object param,
java.lang.Class<?> cls)
throws java.sql.SQLException
- Throws:
java.sql.SQLException
setParameter
public final void setParameter(java.sql.PreparedStatement st,
int index,
java.lang.Object param)
throws java.sql.SQLException
- Throws:
java.sql.SQLException
callStoredProc
public final java.lang.Object[] callStoredProc(java.lang.String name,
java.lang.Object... in)
throws java.sql.SQLException
- Calls stored procedure. Input parameters are set just like in
setParameters(java.sql.PreparedStatement, Object...)
.
- Parameters:
name
- Stored procedure name. SQL statement is generated by procedure name
and parameters count as { call proc_name(in) }
.in
- input/output parameters array (see setParameters(java.sql.PreparedStatement, Object...)
).
Can contain objects of type OutParameter
.
- Returns:
- output parameters values, not null. Table of correspondence of type codes to Java classes:
TINYINT
Byte
SMALLINT
Short
INTEGER
Integer
BIGINT
Long
FLOAT
Float
REAL, DOUBLE
Double
DECIMAL, NUMERIC
BigDecimal
CHAR, VARCHAR
String
BINARY, VARBINARY
byte[]
DATE
Date
TIME
Time
TIMESTAMP
Timestamp
CLOB
String
BLOB
byte[]
OTHER
Object
- Throws:
java.sql.SQLException
callStoredBlock
public final java.lang.Object[] callStoredBlock(java.lang.String block,
java.lang.Object... in)
throws java.sql.SQLException
- Executes PL/SQL block. Other parameters see
callStoredProc(String, Object...)
.
- Parameters:
block
- PL/SQL block text
- Throws:
java.sql.SQLException
callStoredProc
public final java.lang.Object[] callStoredProc(java.lang.String name,
boolean block,
java.lang.Object... in)
throws java.sql.SQLException
- Executes stored procedure or PL/SQL block (depending of
block
parameter).
If block == true
then callStoredBlock(String, Object...)
is executed,
else if block == false
then callStoredProc(String, Object...)
is executed.
- Throws:
java.sql.SQLException
getInterface
public final <T extends LIDBCommon> T getInterface(java.lang.Class<T> iface)
- Returns data access interface generated by preprocessor.
Data access class should be marked with
SQLG
annotation having attribute
SQLG.inline()
= true
.
- Parameters:
iface
- interface class
- Returns:
- data access interface implementation object working
in current transaction
Overview
Package
Class
Tree
Deprecated
Index
Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD