Problem with Processing and SQLJet
in
Contributed Library Questions
•
2 years ago
I want to create a Processing library to record events on a multi-touch interface. I'm trying to achieve this by using SQLJet to easily record events on an SQLite database. I know about the SQLibrary for Processing, but I'm trying to avoid having
write instructions on the Sketches' code.
I'm using the Processing library template for Eclipse, and I've imported the OSGi bundle with SQLJet as an external JAR. I'm testing this simple code that only creates a database:
-
package TUIrecorder;
-
import java.io.File;
-
import org.tmatesoft.sqljet.core.SqlJetException;
-
import org.tmatesoft.sqljet.core.SqlJetTransactionMode;
-
import org.tmatesoft.sqljet.core.table.ISqlJetTransaction;
-
import org.tmatesoft.sqljet.core.table.SqlJetDb;
-
import processing.core.*;
-
public class TUIrecorder {
-
// myParent is a reference to the parent sketch
-
PApplet myParent;
-
File dbFile;
-
/**
-
* Constructor, called in the setup() method in the Processing sketch to start the library.
-
*
-
* @example TUIrecExample
-
* @param theParent
-
*/
-
public TUIrecorder(PApplet theParent) {
-
myParent = theParent;
-
-
try {
-
createDB();
-
} catch (Exception e) {
-
System.out.println("Failed to create the database.");
-
}
-
}
-
/**
-
* Prepares a table in the database to record pick ups and drop downs
-
*
-
* @example TUIrecExample
-
* @throws SqlJetException
-
*/
-
private void createDB() throws SqlJetException {
-
dbFile = new File("db.interaction");
-
dbFile.delete();
-
// create database, table and two indices
-
SqlJetDb db = SqlJetDb.open(dbFile, true);
-
// set DB option that have to be set before running any transactions
-
db.getOptions().setAutovacuum(true);
-
// set DB option that have to be set in a transaction
-
db.runTransaction(new ISqlJetTransaction() {
-
public Object run(SqlJetDb db) throws SqlJetException {
-
db.getOptions().setUserVersion(1);
-
return true;
-
}
-
}, SqlJetTransactionMode.WRITE);
-
-
// close DB
-
db.close();
-
}
-
}
It builds successfully, although I have a warning relating to the
javadoc of
SqlJetException.
When I try to run the following code in Processing:
-
import TUIrecorder.*;
-
TUIrecorder tuiRec;
-
void setup() {
-
size(400,400);
-
smooth();
-
-
tuiRec = new TUIrecorder(this);
-
}
-
void draw() {
- background(0);
- }
I get the following error:
processing.app.debug.RunnerException: NoClassDefFoundError: org/antlr/runtime/RecognitionException
at processing.app.Sketch.placeException(Sketch.java:1543)
at processing.app.debug.Runner.findException(Runner.java:583)
at processing.app.debug.Runner.reportException(Runner.java:558)
at processing.app.debug.Runner.exception(Runner.java:498)
at processing.app.debug.EventThread.exceptionEvent(EventThread.java:367)
at processing.app.debug.EventThread.handleEvent(EventThread.java:255)
at processing.app.debug.EventThread.run(EventThread.java:89)
Exception in thread "Animation Thread" java.lang.NoClassDefFoundError: org/antlr/runtime/RecognitionException
at org.tmatesoft.sqljet.core.table.SqlJetDb$2.runWithLock(SqlJetDb.java:247)
at org.tmatesoft.sqljet.core.table.SqlJetDb.runWithLock(SqlJetDb.java:305)
at org.tmatesoft.sqljet.core.table.SqlJetDb.readSchema(SqlJetDb.java:242)
at org.tmatesoft.sqljet.core.table.SqlJetDb.getOptions(SqlJetDb.java:509)
at TUIrecorder.TUIrecorder.createDB(Unknown Source)
at TUIrecorder.TUIrecorder.
(Unknown Source)
Any clue on what I'm doing wrong here?
1