Apache Commons DbUtils - 1.0
Description
This extension provides support for SQL query execution calls under Apache Commons DbUtils using Java language.
Supported Apache Commons DbUtils methods
All supported methods/properties below are used to execute SQL queries on their corresponding server. Other API methods are considered internally so that the query statements are correctly evaluated.
| Method | Parameter(s) |
|---|---|
org.apache.commons.dbutils.QueryRunner.batch |
Connection conn String sql Object[][] params |
|
String sql Object[][] params |
|
org.apache.commons.dbutils.QueryRunner.execute |
Connection conn String sql Object... params |
|
final Connection conn final String sql final ResultSetHandler final Object... params |
|
|
final String sql final Object... params |
|
|
final String sql final ResultSetHandler final Object... params |
|
org.apache.commons.dbutils.QueryRunner.insert |
Connection conn String sql ResultSetHandler |
|
final Connection conn final String sql final ResultSetHandler final Object... params |
|
|
final String sql final ResultSetHandler |
|
|
final String sql final ResultSetHandler final Object... params |
|
org.apache.commons.dbutils.QueryRunner.insertBatch |
Connection conn String sql ResultSetHandler Object[][] params |
|
final String sql final ResultSetHandler final Object[][] params |
|
org.apache.commons.dbutils.QueryRunner.query |
Connection conn String sql Object param ResultSetHandler |
|
final Connection conn final String sql final Object[] params final ResultSetHandler |
|
|
final Connection conn final String sql final ResultSetHandler |
|
|
final Connection conn final String sql final ResultSetHandler final Object... params |
|
|
final String sql final Object param final ResultSetHandler |
|
|
final String sql final Object[] params final ResultSetHandler |
|
|
final String sql final ResultSetHandler |
|
|
final String sql final ResultSetHandler final Object... params |
|
org.apache.commons.dbutils.QueryRunner.update |
Connection conn String sql |
|
final Connection conn final String sql final Object param |
|
|
final Connection conn final String sql final Object... params |
|
|
final String sql |
|
|
final String sql final Object param |
|
|
final String sql final Object... params |
|
org.apache.commons.dbutils.AsyncQueryRunner.batch |
Connection conn String sql Object[][] params |
|
String sql Object[][] params |
|
org.apache.commons.dbutils.AsyncQueryRunner.insert |
Connection conn String sql ResultSetHandler |
|
final Connection conn final String sql final ResultSetHandler final Object... params |
|
|
final String sql final ResultSetHandler |
|
|
final String sql final ResultSetHandler final Object... params |
|
org.apache.commons.dbutils.AsyncQueryRunner.insertBatch |
Connection conn String sql ResultSetHandler Object[][] params |
|
final String sql final ResultSetHandler final Object[][] params |
|
org.apache.commons.dbutils.AsyncQueryRunner.query |
final Connection conn final String sql final ResultSetHandler |
|
final Connection conn final String sql final ResultSetHandler final Object... params |
|
|
final String sql final ResultSetHandler |
|
|
final String sql final ResultSetHandler final Object... params |
|
org.apache.commons.dbutils.AsyncQueryRunner.update |
Connection conn String sql |
|
final Connection conn final String sql final Object param |
|
|
final Connection conn final String sql final Object... params |
|
|
final String sql |
|
|
final String sql final Object param |
|
|
final String sql final Object... params |
Function Point, Quality and Sizing support
- Function Points (transactions): a green tick indicates that OMG Function Point counting and Transaction Risk Index are supported
- Quality and Sizing: a green tick indicates that CAST can measure size and that a minimum set of Quality Rules exist
| Function Points (transactions) | Quality and Sizing |
|---|---|
| ✅ | ❌ |
What results can you expect?
Objects
| Icon | Object type Description | When is this object created ? |
|---|---|---|
| Apache Commons DbUtils Query | An object is created for each SQL query found and resolved in an Apache Commons DbUtils CRUD method call | |
| Apache Unknown Commons DbUtils Query | An object is created for each SQL query or supported callback detected that could not be resolved correctly. |
Links
The following links will be created by the Apache Commons DbUtils extension, or by other extensions:
| Link type | Caller type | Callee type | Methods Supported |
|---|---|---|---|
| callLink | Java Method | All CRUD methods supported from Apache Commons DbUtils package (see above) | |
| callLink | Java Method | All CRUD methods supported from Apache Commons DbUtils package (see above) | |
| useLink | Apache Commons DbUtils Query | Created by SQL Analyzer when DDL source files are analyzed | |
| callLink | Apache Commons DbUtils Query | ||
| useLink | Apache Commons DbUtils Query | ![]() |
Created by Missing tables and procedures for JEE when the object is not analyzed |
| callLink | Apache Commons DbUtils Query | ![]() |
Samples
txlcn-tc
From txlcn-tc\src\main\java\com\codingapi\txlcn\tc\jdbc\log\TransactionLogExecutor.java
public class TransactionLogExecutor {
private JdbcTransactionDataSource jdbcTransactionDataSource;
private LogExecutor logExecutor;
private QueryRunner queryRunner = new QueryRunner();
public TransactionLogExecutor(LogExecutor logExecutor,JdbcTransactionDataSource jdbcTransactionDataSource) {
this.logExecutor = logExecutor;
this.jdbcTransactionDataSource = jdbcTransactionDataSource;
}
public void saveLog() throws SQLException {
JdbcTransaction jdbcTransaction = JdbcTransaction.current();
//todo insert all
for(TransactionLog transactionLog:jdbcTransaction.getTransactionLogs()) {
String sql = logExecutor.insert(transactionLog);
Connection connection = jdbcTransactionDataSource.getConnection();
int row = queryRunner.execute(connection, sql, transactionLog.params());
log.debug("insert-sql=>{},row:{},connection:{}", sql, row,connection);
}
}
public void init(Connection connection) throws SQLException{
try {
String createSql = logExecutor.create();
queryRunner.execute(connection, createSql);
log.info("transaction log init success .");
}catch (SQLException exception){
log.warn("init transaction-log");
}
}
public void delete(Connection connection)throws SQLException{
List<Long> ids = JdbcTransaction.current().logIds();
String sql = logExecutor.delete(ids);
int row = queryRunner.execute(connection,sql);
log.debug("delete-sql=>{},row:{}",sql,row);
}
}
and from txlcn-tc\src\main\java\com\codingapi\txlcn\tc\jdbc\log\MysqlLogExecutor.java
public class MysqlLogExecutor implements LogExecutor {
@Override
public String insert(TransactionLog transactionLog) {
return "insert into `transaction_log`(`id`,`group_id`,`sql`,`time`,`flag`) values(?,?,?,?,?)";
}
@Override
public String create() {
return "\n" +
"CREATE TABLE `transaction_log` (\n" +
" `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT ' ',\n" +
" `group_id` varchar(40) DEFAULT NULL,\n" +
" `sql` varchar(255) DEFAULT NULL,\n" +
" `time` bigint(20) DEFAULT NULL,\n" +
" `flag` int(1) DEFAULT NULL,\n" +
" PRIMARY KEY (`id`)\n" +
") ENGINE=InnoDB DEFAULT CHARSET=latin1;\n" +
"\n" ;
}
@Override
public String delete(List<Long> ids) {
String id = Joiner.on(",").join(ids);
return "delete from `transaction_log` where id in ("+id+")";
}
}
Three Apache Commons DbUtils objects are created:

Limitations
- Most of tracebacks in evaluating string with common exception AttributeError, TypeError, etc. and evaluation that returns an empty value are currently marked to create an unknown querty object.
- Java Property Mapping is still not perfect.

