-
Feature Request
-
Resolution: Done
-
Major
-
1.3.0.Beta4
-
None
Need to implement a batchlet that executes the specified sql statements, e.g., create, delete, drop, or update.
User should be able to specify multiple sql statements separated by ;
User should be able to specify whether to commit each statement immediately, or group all statements into one transaction. For example, have a batch property autoCommit = true | false. This property should be used if:
- there are multiple sql statements;
- the connection is obtained from DriverManager
Usage examples:
<?xml version="1.0" encoding="UTF-8"?> <job id="JdbcBatchletTest" xmlns="http://xmlns.jcp.org/xml/ns/javaee" version="1.0"> <step id="step1"> <batchlet ref="jdbcBatchlet"> <properties> <!-- run 2 sqls --> <property name="sqls" value=" insert into STOCK_TRADE (TRADEDATE, TRADETIME, OPEN, HIGH, LOW, CLOSE, VOLUMN) VALUES('2017-02-17','15:51',122.25,122.44,122.25,122.44,16800.0); delete from STOCK_TRADE "/> <property name="url" value="jdbc:h2:/Users/cfang/dev/jsr352/jberet-support/target/JdbcReaderWriterTest"/> </properties> </batchlet> </step> </job>
Run a stored procedure with jdbcBatchlet:
<?xml version="1.0" encoding="UTF-8"?> <job id="JdbcBatchletTest" xmlns="http://xmlns.jcp.org/xml/ns/javaee" version="1.0"> <step id="step1"> <batchlet ref="jdbcBatchlet"> <properties> <!-- run the stored procedure sp2, which has already been created in the target db --> <!-- in h2 database, it is defined as --> <!-- CREATE ALIAS IF NOT EXISTS sp2 AS $$ void sp2(Connection conn) throws SQLException { conn.createStatement().executeUpdate("delete from STOCK_TRADE"); }$$; --> <property name="sqls" value="{ call sp2() }"/> <property name="url" value="jdbc:h2:/Users/cfang/dev/jsr352/jberet-support/target/JdbcReaderWriterTest"/> </properties> </batchlet> </step> </job>
- is related to
-
JBERET-379 Implement Cassandra Batchlet to Run Cassandra CQL
- Resolved
- relates to
-
JBERET-57 Implement JDBC ItemReader
- Resolved
-
JBERET-58 Implement JDBC ItemWriter
- Resolved
-
JBERET-264 Support Jpa Item Reader
- Resolved
-
JBERET-265 Support Jpa Item Writer
- Resolved
-
JBERET-307 Implement database stored procedure item reader
- Resolved