1.1.1

Table Of Contents
Implementing the RowLoader Interface
To create a RowLoader, you dene a class that implements the interface com.vmware.sqlre.callbacks.RowLoader,
and then attach your implementation to a table using a system procedure. The implementation then acts as the
SQL data loader.
Procedure
1. Include a public, static method that takes no parameters, and that returns an instance of the loader. For
example:
ExampleRowLoader.java
package example.callbacks;
import java.sql.*;
import javax.sql.*;
import javax.sql.rowset.*;
import com.vmware.sqlfire.callbacks.RowLoader;
public class MyRowLoader implements RowLoader{
public static MyRowLoader create() {
return new ExampleRowLoader();
}
2. Implement an init(String initStr) method to obtain parameters that are dened when you register your
implementation with a table. SQLFire calls your implementation's init() method when the
SYS.ATTACH_LOADER procedure is used to register the RowLoader with a table. All parameters are
passed in the single String object.
3. SQLFire calls the getRow(String schemaName, String tableName, Object[] primarykey) method
implementation to provide the schema name, table name and an array of objects that are the primary key
values (in the order presented by the table denition) each time the loader is invoked to fetch data from the
external source. Your implementatino of this method must return one of the following:
An object array with one element with the value for each column, including the primary key, in the order
dened by the SQLFire table denition.
null, if there is no element found.
An instance of java.sql.ResultSet, possibly the result of a query against another database. Only the rst row
will be used. The result columns should match the SQLFire table.
An empty java.sql.ResultSet if no element is found.
4. After compiling your RowLoader implementation and adding it to the classpath, register the RowLoader
with a table by executing the built-in SYS.ATTACH_LOADER procedure.
Using the JDBCRowLoader Example
The JDBCRowLoader class provide a sample RowLoader implementation that loads data from archive relational
data stores.
Features and Requirements on page 188
JDBCRowLoader Example Implementation on page 189
Features and Requirements
The JDBCRowLoader example has the following features:
It can be implemented for any JDBC data source (provided the driver is available in the classpath of the server)
vFabric SQLFire User's Guide188
Caching Data with vFabric SQLFire