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 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 if 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 if the last parameter. Adding new parameters will be continued after this. Closes existingPreparedStatementif exists and assigns it tonull.- Parameters:
pos- 1 based position- Throws:
SQLException
-
addInt
Adds int parameter in the prepared statement- Parameters:
value-- Returns:
- the current instance
-
addLong
Adds long parameter in the prepared statement- Parameters:
value-- Returns:
- the current instance
-
addBigDecimal
Adds Decimal parameter in the prepared statement- Parameters:
value-- Returns:
- the current instance
-
addString
Adds int parameter in the prepared statement- Parameters:
value-- Returns:
- the current instance
-
addDate
Adds Date parameter in the prepared statement- Parameters:
value-- Returns:
- the current instance
-
addTimestamp
Adds Timestamp parameter in the prepared statement- Parameters:
value-- Returns:
- the current instance
-
addTimestamp
Adds Timestamp parameter in the prepared statement- Parameters:
value-- Returns:
- the current instance
-
addBoolean
Adds Boolean parameter in the prepared statement- Parameters:
value-- Returns:
- the current instance
-
addObjects
Adds parameters with arbitrary types in the prepared statement- Parameters:
values-- Returns:
- the current instance
-
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
-