Package io.codemine.java.postgresql.jdbc
Interface Statement<R>
- Type Parameters:
R- the result type returned bydecodeResultSet(java.sql.ResultSet)ordecodeAffectedRows(long)
public interface Statement<R>
Implemented by each query's parameter+result class. Provides a uniform way to prepare and execute
statements against a JDBC
Connection.-
Method Summary
Modifier and TypeMethodDescriptionvoidBind to the prepared statement's parameter slots.decodeAffectedRows(long affectedRows) Decode an affected-row count into the statement's result type.Decode a result set into the statement's result type.default Rexecute(Connection conn) Execute this statement using the provided JDBC connection.booleanWhether this statement returns rows (i.e. is aSELECTor contains aRETURNINGclause).sql()The SQL text for this statement.
-
Method Details
-
sql
String sql()The SQL text for this statement. Parameter placeholders use JDBC?syntax; custom PostgreSQL types are cast explicitly, e.g.?::album_format.- Returns:
- the SQL text for this statement
-
bindParams
Bind to the prepared statement's parameter slots.- Parameters:
ps- the prepared statement to bind parameters on- Throws:
SQLException- if a database access error occurs while binding
-
returnsRows
boolean returnsRows()Whether this statement returns rows (i.e. is aSELECTor contains aRETURNINGclause). -
decodeResultSet
Decode a result set into the statement's result type.- Parameters:
rs- the result set positioned before the first row- Returns:
- the decoded result of type
R - Throws:
SQLException- if a database access error occurs while decoding
-
decodeAffectedRows
Decode an affected-row count into the statement's result type.- Parameters:
affectedRows- the number of rows affected- Returns:
- the decoded result of type
R - Throws:
SQLException- if a database access error occurs while decoding
-
execute
Execute this statement using the provided JDBC connection.- Parameters:
conn- the JDBC connection to use- Returns:
- the decoded statement result of type
R - Throws:
SQLException- if a database access error occurs while executing the statement
-