Here is code to call a predefined function:
Code: Select all
package brc;
import java.io.IOException;
import ca.mb.armchair.rel3.client.Connection;
import ca.mb.armchair.rel3.client.Response;
import ca.mb.armchair.rel3.client.Value;
import ca.mb.armchair.rel3.client.stream.CrashHandler;
public class RelAccess
{
public static void main (String[] args)
{
Connection connection = new Connection("localhost:5514");
try
{
Response response = connection.evaluate("max(scenarios,sid)", new CrashHandler(){
@Override
public void process (Throwable t)
{
System.out.println("Ouch!" + t.getMessage());
}});
Value value = response.awaitResult(10000);
System.out.println(value.toInt());
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
To use the database directly the connection string "local:C:\\PROGRAMS\\Rel" can be used, but more jars are required.
There may be better ways to do this. I don't know what the CrashHandler should be doing.