The Carbon Java Framework  

The Sql Bean Dataloader Module

Sql Bean Dataloader Usage

Printer Friendly Version

Author: Jordan Reed (jreed at
Version: $Revision: 1.1 $($Author: jdreed $ / $Date: 2003/10/29 18:32:46 $)
Created: October 2003


This module provides implementations for cache service dataloaders that can be used to cache information from jdbc queries into simple java bean objects.


Using the sql bean dataloader requires the following steps:

  1. Create a Java bean to store the data in cache
  2. Create a configuration file

Create a Java bean to store the data in cache

This java bean is the representation of the database information that will be stored in memory. The dataloader will load information from the database into instances of this object and store them int the cache.

Example of a Sql Dataloader Java Bean

public class TwoColumnBeanTest {
    public TwoColumnBeanTest() {

    private BigDecimal key;
    private String value;

    public BigDecimal getKey() {
        return this.key;

    public void setKey(BigDecimal key) {
        this.key = key;

    public String getValue() {
        return this.value;

    public void setValue(String value) {
        this.value = value;

Create a configuration file

The configuration file for the dataloader is used to describe what information is to be loaded from the database and where to put that inside the java bean.



    <DataLoader ConfigurationInterface="">


          <!-- MANDATORY. Refer to the connection factory component configuration here -->

          <!-- OPTIONAL. Configure the map implmentation to be used. if not provided, it is defaulted to java.util.HashMap-->

          <!-- OPTIONAL. Configure the comparator implementation you want to use with the
         respective map implementation. Please note that the map implementation should have constructor available
         for using comparator, otherwise this will throw an InvalidConfigurationException.--> 

          <!-- MANDATORY. Define your SQL query in the tag. The order of columns selected
         does not matter. The sequence of results is maintained if appropriate map implementation is chosen. --> 
         <DataLoadQuery>Select KEY_COLUMN, VALUE_COLUMN from EJFW_BEAN_DATA order by KEY_COLUMN</DataLoadQuery>

          <!-- MANDATORY. Defines the bean that will be returned as a value from the map.
         You need to create a java bean with appropriate accessors and mutators for atributes defined in
         mapping --> 

          <!-- MANDATORY. Defines the column name of the table that provides the key for the
         map. Please note that this is case sensitive. So, should be written in CAPS --> 

          <!-- MANDATORY. Defines the mapping between the column name and bean property.--> 
             <BeanAttribute Key="KEY_COLUMN">key</BeanAttribute>
             <BeanAttribute Key="VALUE_COLUMN">value</BeanAttribute>



Copyright © 2001-2003, Sapient Corporation