|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.sqlproc.engine.jdbc.JdbcQuery
public class JdbcQuery
The JDBC stack implementation of the SQL Engine query contract. In fact it's an adapter the internal JDBC stuff.
For more info please see the Tutorials.
Field Summary | |
---|---|
(package private) static Pattern |
CALL
|
(package private) Connection |
connection
The connection to the database. |
(package private) Integer |
firstResult
The first row to retrieve. |
(package private) List<String> |
identities
The collection of all (auto-generated) identities. |
(package private) Map<String,IdentitySetter> |
identitySetters
The collection of all identities setters. |
(package private) Map<String,Object> |
identityTypes
The collection of all identities types. |
(package private) org.slf4j.Logger |
logger
The internal slf4j logger. |
(package private) Integer |
maxResults
The maximum number of rows to retrieve. |
(package private) Map<String,OutValueSetter> |
parameterOutValueSetters
The collection of all parameters output value setters. |
(package private) Map<Integer,Integer> |
parameterOutValuesToPickup
The collection of all parameters, which have to be picked-up. |
(package private) Map<String,Object> |
parameterOutValueTypes
The collection of all parameters types for output values. |
(package private) List<String> |
parameters
The collection of all parameters (input value declarations). |
(package private) Map<String,Object> |
parameterTypes
The collection of all parameters types. |
(package private) Map<String,Object> |
parameterValues
The collection of all parameters values. |
(package private) String |
queryString
The SQL query/statement command. |
(package private) List<String> |
scalars
The collection of all scalars (output values declarations). |
(package private) Map<String,Object> |
scalarTypes
The collection of all scalars types. |
(package private) Integer |
timeout
A timeout for the underlying query. |
Constructor Summary | |
---|---|
JdbcQuery(Connection connection,
String queryString)
Creates a new instance of this adapter. |
Method Summary | |
---|---|
SqlQuery |
addScalar(String columnAlias)
Declares a scalar query result, which is an SQL query execution output value. |
SqlQuery |
addScalar(String columnAlias,
Object type)
Declares a scalar query result, which is an SQL query execution output value. |
Object |
callFunction()
Executes the statements in the stored function, which return value of any type but the result set. |
List |
callList()
Returns the stored procedure execution results as a List. |
Object |
callUnique()
Convenience method to return a single instance that matches the stored procedure execution, or null if the stored procedure execution returns no results. |
int |
callUpdate()
Executes the update, delete, insert statement or other statements in the stored procedure, which don't return the result set. |
protected void |
doIdentitySelect(String identityName)
Runs the select to obtain the value of auto-generated identity. |
protected Object |
getParameters(CallableStatement cs,
boolean isFunction)
Gets the value of the designated OUT parameters. |
Object |
getQuery()
Returns the internal representation of this query. |
protected List |
getResults(ResultSet rs)
Gets the value of the designated columns as the objects in the Java programming language. |
List |
list()
Returns the query results as a List. |
SqlQuery |
setFirstResult(int firstResult)
Sets the first row to retrieve. |
protected int |
setLimits(PreparedStatement ps,
SqlUtils.LimitType limitType,
int ix,
boolean afterSql)
Sets the limit related parameters. |
SqlQuery |
setMaxResults(int maxResults)
Sets the maximum number of rows to retrieve. |
SqlQuery |
setParameter(String name,
Object val)
Binds a value to a named query parameter. |
SqlQuery |
setParameter(String name,
Object val,
Object type)
Binds a value to a named query parameter. |
SqlQuery |
setParameterList(String name,
Object[] vals)
Binds multiple values to a named query parameter. |
SqlQuery |
setParameterList(String name,
Object[] vals,
Object type)
Binds multiple values to a named query parameter. |
protected void |
setParameters(PreparedStatement ps,
SqlUtils.LimitType limitType,
int start)
Sets the value of the designated parameters. |
SqlQuery |
setTimeout(int timeout)
Sets a timeout for the underlying query. |
Object |
unique()
Convenience method to return a single instance that matches the query, or null if the query returns no results. |
int |
update()
Executes the update, delete or insert statement. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
final org.slf4j.Logger logger
Connection connection
String queryString
List<String> scalars
Map<String,Object> scalarTypes
List<String> parameters
Map<String,Object> parameterValues
Map<String,Object> parameterTypes
Map<String,Object> parameterOutValueTypes
Map<String,OutValueSetter> parameterOutValueSetters
Map<Integer,Integer> parameterOutValuesToPickup
List<String> identities
Map<String,IdentitySetter> identitySetters
Map<String,Object> identityTypes
Integer timeout
Integer firstResult
Integer maxResults
static final Pattern CALL
Constructor Detail |
---|
public JdbcQuery(Connection connection, String queryString)
connection
- the connection to the databasequeryString
- the SQL query/statement commandMethod Detail |
---|
public Object getQuery()
getQuery
in interface SqlQuery
public SqlQuery setTimeout(int timeout)
setTimeout
in interface SqlQuery
timeout
- the timeout in seconds
public SqlQuery setFirstResult(int firstResult)
setFirstResult
in interface SqlQuery
firstResult
- a row number, numbered from 0
public SqlQuery setMaxResults(int maxResults)
setMaxResults
in interface SqlQuery
maxResults
- the maximum number of rows
public List list() throws SqlProcessorException
list
in interface SqlQuery
SqlProcessorException
- in the case of any problem in ORM or JDBC stackpublic Object unique() throws SqlProcessorException
unique
in interface SqlQuery
SqlProcessorException
- in the case of any problem in ORM or JDBC stackpublic int update() throws SqlProcessorException
update
in interface SqlQuery
SqlProcessorException
- in the case of any problem in ORM or JDBC stackprotected void doIdentitySelect(String identityName)
identityName
- the identity name from the META SQL statementpublic List callList() throws SqlProcessorException
callList
in interface SqlQuery
SqlProcessorException
- in the case of any problem in ORM or JDBC stackpublic Object callUnique() throws SqlProcessorException
callUnique
in interface SqlQuery
SqlProcessorException
- in the case of any problem in ORM or JDBC stackpublic int callUpdate() throws SqlProcessorException
callUpdate
in interface SqlQuery
SqlProcessorException
- in the case of any problem in ORM or JDBC stackpublic Object callFunction() throws SqlProcessorException
callFunction
in interface SqlQuery
SqlProcessorException
- in the case of any problem in ORM or JDBC stackpublic SqlQuery addScalar(String columnAlias)
addScalar
in interface SqlQuery
columnAlias
- the name of the database column or the alias in the result set
public SqlQuery addScalar(String columnAlias, Object type)
addScalar
in interface SqlQuery
columnAlias
- the name of the database column or the alias in the result settype
- the (META) type of the parameter
public SqlQuery setParameter(String name, Object val) throws SqlProcessorException
setParameter
in interface SqlQuery
name
- the name of the parameterval
- the not-null parameter value
SqlProcessorException
- in the case of any problem in ORM or JDBC stackpublic SqlQuery setParameter(String name, Object val, Object type) throws SqlProcessorException
setParameter
in interface SqlQuery
name
- the name of the parameterval
- the possibly-null parameter valuetype
- the (META) type of the parameter
SqlProcessorException
- in the case of any problem in ORM or JDBC stackpublic SqlQuery setParameterList(String name, Object[] vals) throws SqlProcessorException
setParameterList
in interface SqlQuery
name
- the name of the parametervals
- a collection of values
SqlProcessorException
- in the case of any problem in ORM or JDBC stackpublic SqlQuery setParameterList(String name, Object[] vals, Object type) throws SqlProcessorException
setParameterList
in interface SqlQuery
name
- the name of the parametervals
- a collection of valuestype
- the (META) type of the parameter
SqlProcessorException
- in the case of any problem in ORM or JDBC stackprotected void setParameters(PreparedStatement ps, SqlUtils.LimitType limitType, int start) throws SQLException, SqlProcessorException
ps
- an instance of PreparedStatementlimitType
- the limit type to restrict the number of rows in the result setstart
- the index of the first parameter to bind to prepared statement
SQLException
- if a database access error occurs or this method is called on a closed PreparedStatement
SqlProcessorException
protected int setLimits(PreparedStatement ps, SqlUtils.LimitType limitType, int ix, boolean afterSql) throws SQLException
ps
- an instance of PreparedStatementlimitType
- the limit type to restrict the number of rows in the result setix
- a column indexafterSql
- an indicator it's done after the main SQL statement execution
SQLException
- if a database access error occurs or this method is called on a closed PreparedStatement
protected Object getParameters(CallableStatement cs, boolean isFunction) throws SQLException
cs
- an instance of CallableStatement
SQLException
- if a database access error occurs or this method is called on a closed CallableStatement
protected List getResults(ResultSet rs) throws SQLException
rs
- an instance of ResultSet
SQLException
- if a database access error occurs or this method is called on a closed ResultSet
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |