Execute AFL commands from Java


#1

I’m currently programming in Java to communicate with SciDB. The one thing I’m having issues with is that I can only execute AQL commands.
I try the following:

Connection conn = DriverManager.getConnection("jdbc:scidb://hostname:1239/");
Statement st = conn.createStatement();
ResultSet rs = st.executeQuery("create array test <x:int64, y:int64> [i=0:*,100,0]");

and it works, but when I replace the AQL command with an AFL command, I receive an error like this:

Failed query id: 1100892265175
	at org.scidb.jdbc.Statement.executeInternal(Unknown Source)
	at org.scidb.jdbc.Statement.executeQuery(Unknown Source)
	at dt2db.DataTurbineToSciDB.main(DataTurbineToSciDB.java:23)
Caused by: org.scidb.client.Error: UserQueryException in file: src/query/parser/QueryParser.cpp function: parse line: 73
Error id: scidb::SCIDB_SE_PARSER::SCIDB_LE_QUERY_PARSING_ERROR
Error description: Error during query parsing. Query parser failed with error 'syntax error, unexpected identifier'.
list()
^^^^

I just want to be able to exectue AFL commands, and I’m unsure on how to.


#2

Hi, by default JDBC driver use AQL (as Java connector do). But while Java driver have argument to switch to AFL, JDBC standard classes do not have such. Happily JDBC allow to access to DBMS features so we added interfaces org.scidb.jdbc.IStatementWrapper (and org.scidb.jdbc.IResultSetWrapper) which expose some SciDB-only stuff:

import org.scidb.jdbc.IStatementWrapper; ... Connection conn = DriverManager.getConnection("jdbc:scidb://host:1239/"); Statement st = conn.createStatement(); IStatementWrapper stWrapper = st.unwrap(IStatementWrapper.class); stWrapper.setAfl(true); ...

Hope it helps you.