Skip to content
/ quick Public

Framework for high-performance JDBC batch operations

Notifications You must be signed in to change notification settings

dhis2/quick

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

93 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Quick

Quick is a Java framework for high-performance, JDBC batch operations.

View the Javadoc.

StatementManager and StatementHolder

The statement manager and holder allow you to perform JDBC SQL operations against a single connection and statement. Example usage:

@Autowired
StatementManager statementManager;

int sum = 0;

statementManager.initialise();

StatementHolder statementHolder = statementManager.getHolder();

for ( int i = 0; i < 10; i++ )
{
    sum += statementHolder.queryForInteger( "select sum(value) from item where id = " + i );
}

statementManager.destroy();

BatchHandler

The BatchHandler interface allows for batch insert operations and high-performance SQL operations. You can subclass the AbstractBatchHandler class and create implementations for your data objects. Example usage:

@Autowired
BatchHandlerFactory batchHandlerFactory;

BatchHandler<DataElement> batchHandler = batchHandlerFactory
    .createBatchHandler( DataElementBatchHandler.class ).init();

for ( DataElement dataElement : dataElements )
{
    if ( !batchHandler.objectExists( dataElement ) )
    {
        batchHandler.addObject( dataElement ); // Will batch and flush automatically
    }
}

batchHandler.flush(); // Flush remaining objects to database

Spring configuration

Quick components can easily be configured in Spring and used as Spring managed beans.

JDBC configuration

Quick requires that JDBC connection information is specified for the JdbcConfigurationFactoryBean in order to connect to your datababase.

<bean id="jdbcConfiguration" class="org.hisp.quick.configuration.JdbcConfigurationFactoryBean">
  <property name="dialectName" value="H2"/>
  <property name="driverClass" value="org.h2.Driver"/>
  <property name="connectionUrl" value="jdbc:h2:~/h2database/quick"/>
  <property name="username" value="sa"/>
  <property name="password" value=""/>
</bean>

StatementManager

The StatementManager interface provides methods for performing batch operations against a single JDBC connection and statement.

<bean id="statementManager" class="org.hisp.quick.statement.JdbcStatementManager">
  <property name="jdbcConfiguration" ref="jdbcConfiguration"/>
</bean>

BatchHandlerFactory

The BatchHandlerFactory provides generation of BatchHandler instances which allows for performing batch insert operations for objects.

<bean id="batchHandlerFactory" class="org.hisp.quick.factory.DefaultBatchHandlerFactory">
  <property name="jdbcConfiguration" ref="jdbcConfiguration"/>
</bean>

About

Framework for high-performance JDBC batch operations

Resources

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages