Package net.sf.basedb.core
Class AnnotationBatcher.InsertBatcher
- java.lang.Object
-
- net.sf.basedb.core.AnnotationBatcher.InsertBatcher
-
- Enclosing class:
- AnnotationBatcher
static class AnnotationBatcher.InsertBatcher extends Object
Batcher implementation for inserting into tables. Assumes that the table has an "id" column that is auto-generated by the SQL statement. The value of the generated id is retuned by theinsert(Object[])
method.
-
-
Field Summary
Fields Modifier and Type Field Description private int[]
parameterTypes
private String
sql
private PreparedStatement
statement
-
Constructor Summary
Constructors Constructor Description InsertBatcher(Connection c, String sql, int... parameterTypes)
Prepare a new batcher for the given SQL statement.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) void
close()
Close the batcher.(package private) String
getSql()
The SQL statement this batcher is executing.(package private) int
insert(Object... values)
Execute an insert SQL statement with the given parameter values.
-
-
-
Field Detail
-
sql
private final String sql
-
statement
private final PreparedStatement statement
-
parameterTypes
private final int[] parameterTypes
-
-
Constructor Detail
-
InsertBatcher
InsertBatcher(Connection c, String sql, int... parameterTypes) throws SQLException
Prepare a new batcher for the given SQL statement.- Parameters:
sql
- A SQL statementparameterTypes
- Parameter type codes as defined inTypes
.- Throws:
SQLException
-
-
Method Detail
-
getSql
String getSql()
The SQL statement this batcher is executing.
-
insert
int insert(Object... values) throws SQLException
Execute an insert SQL statement with the given parameter values. The number of values must match the number of parameter types.- Returns:
- The ID of inserted row
- Throws:
SQLException
-
close
void close()
Close the batcher.
-
-