Class PreparedQuery
java.lang.Object
org.bgerp.util.sql.PreparedQuery
- All Implemented Interfaces:
AutoCloseable
- Direct Known Subclasses:
PreparedDelay
Dynamically builds of
PreparedStatement.
Allows adding params without definition of position number.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddBigDecimal(BigDecimal value) Adds Decimal parameter in the prepared statementaddBoolean(Boolean value) Adds Boolean parameter in the prepared statementAdds Date parameter in the prepared statementaddInt(int value) Adds int parameter in the prepared statementaddLong(long value) Adds a long parameter in the prepared statementaddObjects(Object... values) Adds parameters with arbitrary types in the prepared statementAdds SQL string to the queryAdds int parameter in the prepared statementaddTimestamp(Timestamp value) Adds Timestamp parameter in the prepared statementaddTimestamp(Date value) Adds Timestamp parameter in the prepared statementvoidclose()intExecutes the prepared insert statementExecutes the prepared statement for selectintExecutes the prepared statement for updategetQuery()Deprecated.voidsetPos(int pos) Changes position of the last parameter.voidReplaces the current querytoString()
-
Constructor Details
-
PreparedQuery
-
PreparedQuery
-
-
Method Details
-
getPrepared
- Returns:
PreparedStatementornullif not created
-
getQuery
-
addQuery
Adds SQL string to the query- Parameters:
value-- Returns:
- the current object
-
setQuery
-
setPos
Changes position of the last parameter. Adding new parameters will be continued after this. Closes existingPreparedStatementif exists and assigns it tonull.- Parameters:
pos- the position starting from 1- Throws:
SQLException
-
addInt
Adds int parameter in the prepared statement- Parameters:
value-- Returns:
this
-
addLong
Adds a long parameter in the prepared statement- Parameters:
value- the parameter- Returns:
this
-
addBigDecimal
Adds Decimal parameter in the prepared statement- Parameters:
value-- Returns:
this
-
addString
Adds int parameter in the prepared statement- Parameters:
value-- Returns:
this
-
addDate
Adds Date parameter in the prepared statement- Parameters:
value-- Returns:
this
-
addTimestamp
Adds Timestamp parameter in the prepared statement- Parameters:
value-- Returns:
this
-
addTimestamp
Adds Timestamp parameter in the prepared statement- Parameters:
value-- Returns:
this
-
addBoolean
Adds Boolean parameter in the prepared statement- Parameters:
value-- Returns:
this
-
addObjects
Adds parameters with arbitrary types in the prepared statement- Parameters:
values-- Returns:
this
-
executeQuery
Executes the prepared statement for select- Returns:
- the result set
- Throws:
SQLException
-
executeUpdate
Executes the prepared statement for update- Returns:
- the number of updated rows
- Throws:
SQLException
-
executeInsert
Executes the prepared insert statement- Returns:
- generated ID
- Throws:
SQLException
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-
toString
-