Package overit.geocall.sql
Interface DBStatement
- All Superinterfaces:
AutoCloseable,DataAttributesHolder
- All Known Implementing Classes:
StandardDBStatement
The class is an Interface that defines the operativity of a generic statement used to access the database
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final LogChanneluse this strings in methods likesetSqlIn(String, String, Object[])orsetSqlOut(String, String, Object[])to include or exclude clauses with parameters meaningempty -
Method Summary
Modifier and TypeMethodDescriptionvoidaddBatch()Adds a set of parameters to the statement object's batch of commands.voidaddBatch(int batchSize) Adds a set of parameters to the statement object's batch of commands.voidclose()Closes the SQL statementcreateCall(String call) Explicitly creates a PreparedStatement.voiddefine(String field, DBObjectMap dbom) Specifies aDBObjectMapthat must be used to load a column resulting from a SELECTvoiddefineParam(String field, DBObjectMap dbom) Explicitly specifies aDBObjectMapthat must be used to prepare the statement for a specific variable in the SQL string.int[]Submits a batch of commands to the database for execution and if all commands execute successfully, returns an array of update counts.Translates the statement, compiles and execute itexecuteQuery(boolean readonly) Deprecated.intTranslates the statement, compiles and execute itReturns theDBTypeassociated to thePooledConnectioncurrently in use.Executes the SQL query in this statement object and returns theResultSetobject generated by the queryreads the result set raw at the current position and construct a key-value map af all the fields according to the statement specificationReturns the java.sql Statement on which the DBstatement actsbooleanReturnstruein case aSQL INSERTquery is in progress;falseotherwise.booleanReturnstruein case aSQL UPDATEquery is in progress;falseotherwise.voidextracts aDBCursorfrom the statement and submits it to an explicit scanning prcedurevoidSets the value of a variable ?voidSets the values of all the variables ?voidsetMaxRows(int n) Sets the maximum number of rows to searchvoidsetSkipRows(int n) Sets the number of initial rows to be skipped.voidSets the SQL string of the statement.voidSets the SQL Fragment of the statement.voidSets conditionally the SQL string of the statement.voidsetSqlIn(String sql, String key, Collection<?> objects) Sets conditionally the SQL string of the statement.voidSets conditionally the SQL string of the statement.voidSets conditionally the SQL string of the statement.voidsetSqlOut(String sql, String key, Collection<?> objects) Sets conditionally the SQL string of the statement.voidsetUpdatable(boolean updatable) Sets if theResultSetis updatableMethods inherited from interface overit.geocall.edm.model.DataAttributesHolder
getDataAttributes, getEntities, setDataAttributes
-
Field Details
-
LOG
-
NULL_STRINGS_FOR_LIKE
use this strings in methods likesetSqlIn(String, String, Object[])orsetSqlOut(String, String, Object[])to include or exclude clauses with parameters meaningempty
-
-
Method Details
-
setSql
Sets the SQL string of the statement.
The string contains variables like @field that can be properly converted in a DB field name or like ?value. Those must be different and must be expressly set by one of the methodset(map)orset(key,value)- Parameters:
sql- The SQL string
-
setSqlOn
Sets conditionally the SQL string of the statement.
The SQL string is inserted into the statement only if it will be set to the statement (with one of the methodsset(map)orset(key,value)) a key that corresponds to the key passed as second parameter- Parameters:
sql- The SQL stringkey- The key that must be set to the statement
-
setSqlIn
Sets conditionally the SQL string of the statement.
The SQL string is inserted into the statement only if it will be set to the statement with one of the methodsset(map)orset(key,value)) a key that corresponds to the key passed as second parameter and the object associated to the key is equal to one of the objects passed as third parameter- Parameters:
sql- The SQL stringkey- The key that must be set to the statementobjects- The array of Objects used for comparison
-
setSqlOut
Sets conditionally the SQL string of the statement.
The SQL string is inserted into the statement only if it will be set to the statement with one of the methodsset(map)orset(key,value)) a key that corresponds to the key passed as second parameter and the object associated to the key is different to all of the objects passed as third parameter- Parameters:
sql- The SQL stringkey- The key that must be set to the statementobjects- The array of Objects used for comparison
-
setSqlIn
Sets conditionally the SQL string of the statement.
The SQL string is inserted into the statement only if it will be set to the statement with one of the methodsset(map)orset(key,value)) a key that corresponds to the key passed as second parameter and the object associated to the key is equal to one of the objects passed as third parameter- Parameters:
sql- The SQL stringkey- The key that must be set to the statementobjects- The collection of Objects used for comparison
-
setSqlOut
Sets conditionally the SQL string of the statement.
The SQL string is inserted into the statement only if it will be set to the statement with one of the methodsset(map)orset(key,value)) a key that corresponds to the key passed as second parameter and the object associated to the key is different to all of the objects passed as third parameter- Parameters:
sql- The SQL stringkey- The key that must be set to the statementobjects- The collection of Objects used for comparison
-
setSql
Sets the SQL Fragment of the statement.
The string contains variables like @field that can be properly converted in a DB field name or like ?value. Those must be different and must be expressly set by one of the methodset(map)orset(key,value)- Parameters:
sql- The SQL Fragment
-
setMaxRows
void setMaxRows(int n) Sets the maximum number of rows to search- Parameters:
n- Maximum number of rows
-
setUpdatable
void setUpdatable(boolean updatable) Sets if theResultSetis updatable- Parameters:
updatable- iftruetheResultSetis updatable, otherwisefalse
-
setSkipRows
void setSkipRows(int n) Sets the number of initial rows to be skipped. Even these lines, although skipped, are counted in the maxrows parameter.- Parameters:
n- Number of rows to be skipped
-
set
Sets the value of a variable ?value. With this method one value of an SQL statement is compiled. These value can be appropriately converted by a converter (like theDBObjectMap) before being passed to the DB- Parameters:
k- The name of the variable ?value in the SQL stringo- The value of the variable ?value in the SQL string
-
set
Sets the values of all the variables ?value. With this method all the values of an SQL statement are compiled. These values can be appropriately converted by a converter (like theDBObjectMap) before being passed to the DB- Parameters:
map- The map in which each entry defines the value of a variable ?value
-
define
Specifies aDBObjectMapthat must be used to load a column resulting from a SELECT- Parameters:
field- The name of the column of the ResultSet obtained from a querydbom- The object that can map every object in the column
-
defineParam
Explicitly specifies aDBObjectMapthat must be used to prepare the statement for a specific variable in the SQL string.- Parameters:
field- The name of the variable in the SQL stringdbom- The object that can map every object specified for the variable
-
executeUpdate
Translates the statement, compiles and execute it- Returns:
- The number of the rows updated or inserted into the database
- Throws:
SQLException- If the communication with the database throws an exception, that it is raised to the caller
-
executeQuery
Translates the statement, compiles and execute it- Returns:
- The view resulting for the SQL query, totally kept in RAM
- Throws:
SQLException- If the communication with the database throws an exception, that it is raised to the caller
-
executeQuery
Deprecated.usedbStatement.executeQuery()ordbStatement.executeQuery().setRoData()insteadTranslates the statement, compiles and execute it- Parameters:
readonly- true if the result must be not modifiable, false otherwise- Returns:
- The DBView resulting for the SQL query, totally kept in RAM
- Throws:
SQLException- If the communication with the database throws an exception, that it is raised to the caller
-
close
Closes the SQL statement- Specified by:
closein interfaceAutoCloseable- Throws:
SQLException- If the communication with the database throws an exception, that it is raised to the caller
-
getStatement
Returns the java.sql Statement on which the DBstatement acts- Returns:
- SQL statement used to access the database
- Throws:
SQLException- If the communication with the database throws an exception, that it is raised to the caller
-
createStatement
Explicitly creates a PreparedStatement. It is useful when you want to use a PreparedStatement and also have the same release mechanisms of the DBStatement- Returns:
- The PreparedStatement created and used to access the database
- Throws:
SQLException- If the communication with the database throws an exception, that it is raised to the caller
-
addBatch
Adds a set of parameters to the statement object's batch of commands. SeeStatement.addBatch(String)- Throws:
SQLException- If the communication with the database throws an exception, that it is raised to the caller
-
addBatch
Adds a set of parameters to the statement object's batch of commands. SeeStatement.addBatch(String).- Parameters:
batchSize- size of the batch (useful for executing the batch whenever the batch size reaches this value).- Throws:
SQLException- If the communication with the database throws an exception, that it is raised to the caller.
-
executeBatch
Submits a batch of commands to the database for execution and if all commands execute successfully, returns an array of update counts. SeeStatement.executeBatch()- Returns:
- An array of update counts containing one element for each command in the batch. The elements of the array are ordered according to the order in which commands were added to the batch
- Throws:
SQLException- If the communication with the database throws an exception, that it is raised to the caller
-
getResultSet
Executes the SQL query in this statement object and returns theResultSetobject generated by the query- Returns:
- The
ResultSetobject that contains the data produced by the query - Throws:
SQLException- If the communication with the database throws an exception, that it is raised to the caller
-
scan
extracts aDBCursorfrom the statement and submits it to an explicit scanning prcedure- Parameters:
dbs- the scanning procedure- Throws:
SQLException- if some sql error happens in the scanning procedure
-
getRowMapFromResultSet
reads the result set raw at the current position and construct a key-value map af all the fields according to the statement specification- Parameters:
rs- the result set- Returns:
- the key-value map
- Throws:
SQLException- if some sql error happens in the record loading
-
createCall
- Throws:
SQLException
-
isUpdateInProgress
boolean isUpdateInProgress()Returnstruein case aSQL UPDATEquery is in progress;falseotherwise.- Returns:
truein case aSQL UPDATEquery is in progress;falseotherwise.
-
isInsertInProgress
boolean isInsertInProgress()Returnstruein case aSQL INSERTquery is in progress;falseotherwise.- Returns:
truein case aSQL INSERTquery is in progress;falseotherwise.
-
getDbType
DBType getDbType()Returns theDBTypeassociated to thePooledConnectioncurrently in use.- Returns:
- the
DBTypeassociated to thePooledConnectioncurrently in use.
-
dbStatement.executeQuery()ordbStatement.executeQuery().setRoData()instead