Package org.bgerp.util.sql
Class PreparedQuery
java.lang.Object
org.bgerp.util.sql.PreparedQuery
- All Implemented Interfaces:
Closeable
,AutoCloseable
- Direct Known Subclasses:
PreparedDelay
Dynamically builds of
PreparedStatement
.
Allows adding params without definition of position number.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddBigDecimal
(BigDecimal value) Adds Decimal parameter in the prepared statement.addBoolean
(Boolean value) Adds Boolean parameter in the prepared statement.Adds Date parameter in the prepared statement.addInt
(int value) Adds int parameter in the prepared statement.addLong
(long value) Adds long parameter in the prepared statementaddObjects
(Object... values) Adds parameters with arbitrary types in the prepared statement.Adds SQL string to the query.Adds int parameter in the prepared statement.addTimestamp
(Timestamp value) Adds Timestamp parameter in the prepared statement.addTimestamp
(Date value) Adds Timestamp parameter in the prepared statement.void
close()
int
Executes the prepared insert statement.Executes the prepared statement for select.int
Executes the prepared statement for update.getQuery()
Deprecated.void
setPos
(int pos) Changes position if the last parameter.void
Replaces the current query.toString()
-
Constructor Details
-
PreparedQuery
-
PreparedQuery
-
-
Method Details
-
getPrepared
- Returns:
PreparedStatement
ornull
if not created.
-
getQuery
Deprecated.- Returns:
- current query.
-
addQuery
Adds SQL string to the query.- Parameters:
value
-- Returns:
- the current object.
-
setQuery
Replaces the current query.- Parameters:
value
-
-
setPos
Changes position if the last parameter. Adding new parameters will be continued after this. Closes existingPreparedStatement
if 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:
- Throws:
SQLException
-
executeUpdate
Executes the prepared statement for update.- Returns:
- Throws:
SQLException
-
executeInsert
Executes the prepared insert statement.- Returns:
- generated ID.
- Throws:
SQLException
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
toString
-