Skip to content
Dmitry Romanov edited this page Oct 26, 2017 · 5 revisions

RCDB Java API overview

Java API allows one to read RCDB condition values for the run. It doesn't provide possibility of run selection queries at this point.

Installation

Java API comes as sources (in Kotlin) and as ready to use Java precompiled .jar file


Getting values

The example shows how to get values from RCDB:

import org.rcdb.*;
//...
        // Connect to the database 
        // The real HallD database is going to be used for the example
        JDBCProvider provider = RCDB.createProvider("mysql://rcdb@hallddb.jlab.org/rcdb");
        provider.connect();

        // get event count as a long value for run number 31000
        long eventCount = provider.getCondition(31000, "event_count").toLong();
        System.out.println("event_count = " + eventCount);

Here is the list of condition to[Type] functions and what values they are for:

Long toLong();                         /// For int values
Bool toBool();                         /// For bool or int in DB
Double toDouble();                     /// For Double or int in DB
String toString();                     /// For Json, String or Blob
Date   toDate();                       /// For time value

org.rcdb.ValueTypes                    /// type enum

Examples

Examples are located in $RCDB_HOME/java/src/javaExamples folder.


List of examples:

Simple example - shows how to read values from database and lists all condition types from DB

$RCDB_HOME/java/src/javaExamples/SimpleExample.java


Kotlin

There are also an example written in $RCDB_HOME/java/src/kotlinExamples/main.kt