JDBCFetch

Gathers information from a database and places it within a given RecordHandler organized according to how the data is arranged within the chosen database.

Reason for use

Connection with different types of databases is essential to effectively populating a VIVO instance with viable data. Java Database Connectivity is available and flexible, while allowing standard SQL queries to retrieve the information from the chosen database.

Parameters

The parameters for the tool can be placed in the specified config file.

wordiness

wordiness - (optional) sets the lowest level of log messages to be displayed to the console. The lower the log level, the more detailed the messages.
Possible Values:

JDBCFetch Specific messages

Info:

Debug:

Trace:

relational database

The proper information for the connection to the relational database

The database table information

Overview

JDBCFetch is used to ingest data from RDB/JDBC interface. Brings in data from relational database sources defined by the configuration file and converts them to XML, most likely within a RecordHandler.

Short Option

Long Option

Parameter Value Map

Description

Required

d

driver

JDBC_DRIVER

jdbc driver class

true

c

connection

JDBC_CONN

jdbc connection string

true

u

username

USERNAME

database username

true

p

password

PASSWORD

database password

true

o

output

CONFIG_FILE

config file for output record handler

true

O

outputOverride

VALUE

override the RH_PARAM of output record handler using VALUE

false

t

tableName

TABLE_NAME

a single database table name [have multiple -t for more table names]

false

Q

query

SQL_QUERY

use SQL_QUERY to select from TABLE_NAME

false

I

id

ID_FIELD_LIST

use columns in ID_FIELD_LIST [comma separated] as identifier for TABLE_NAME

false

F

fields

FIELD_LIST

fetch columns in FIELD_LIST [comma separated] for TABLE_NAME

false

R

relations

RELATION_PAIR_LIST

fetch columns in RELATION_PAIR_LIST [comma separated] for TABLE_NAME

false

W

whereClause

CLAUSE_LIST

filter TABLE_NAME records based on conditions in CLAUSE_LIST [comma separated]

false

T

tableFromClause

TABLE_LIST

add tables to use in from clauses for TABLE_NAME

false

 

delimiterPrefix

DELIMITER

Prefix each field in the query with this character

false

 

delimiterSuffix

DELIMITER

Suffix each field in the query with this character

false

Usage

JDBCFetch is often the first part of a harvest of data from a standard relational database. It pulls the information into a local RecordHandler which can then be Translated before being transfered into a jena model.

Define Alias

JDBCFetch="java $OPTS Xms$MIN_MEM -Xmx$MAX_MEM -Dharvester-task=$HARVESTER_TASK -Dprocess-task=JDBCFetch -cp bin/harvester$VERSION.jar:bin/dependency/* org.vivoweb.harvester.fetch.JDBCFetch"

Invocation

$JDBCFetch -X config/tasks/DSR-JDBCFetch.xml

Configuration file example

<?xml version="1.0" encoding="UTF-8"?>
<Task type="org.vivoweb.ingest.fetch.JDBCFetch">
  <Param id="driver">com.mysql.jdbc.Driver</Param>
  <Param id="connection">jdbc:mysql://127.0.0.1:3306/jdbcdemoharvest</Param>
  <Param id="username">jdbcDemoHarvest</Param>
  <Param id="password">EFaY6nSxBNpL7cYb</Param>
  <Param id="output">config/recordHandlers/JDBCXMLRecordHandler.xml</Param>
</Task>

Flowchart

Methods

getParser

  1. parse the arguments from the parameter list above

buildSelect

  1. start a stringbuilder
  2. append and assemble the "select" part of the statement
  3. append the relations
  4. append the id fields of the table
  5. append the "from" clauses
  6. end query string with "where" clauses

execute

  1. iterate over table names
    1. buildSelect assembles a SQL select statement string specific for each table
    2. executeQuery on table with the SQL string using the SQL Statement object
    3. Make an RDF/XML record for each result of the query

main

  1. Start Logger
  2. Run JDBCFetch.execute passing the args[] to the constructor
  3. catch errors
    1. IllegalArgumentException
    2. IOException
    3. Exception