Hello all,

I've a problem with a very fool piece of code, but, I don't know why is not
working. The thing is that I want to get some data from a SPARQL endpoint,
and add it to the database.

The idea is that the data from the endpoint can be updated from time to
tome, so, I use set theory to see the differences and only add the new data
to my Apache derby db.

I use the following code:

Logic: http://pastebin.com/RLECrsdX
DerbyDBManager: http://pastebin.com/8KWbpVNf

(I left only the "interesting part").

So, from my main, I execute this code:

Logic l = new Logic(Constants.JENA, Constants.HERMIT,
 Constants.FROM_INPUT_TO_OUTPUT);
if (l.prepareDB().getResult()) {
l.loadInAndOutsToDB();
 }

First of all, I "prepare the db" (prepareDB()) that basically load the
driver, protocol and so on and creates the connection. After that, I check
if the basic tables exists. If not, I create them
(DerbyDBManager.createSchema()).

After that, I execute Logic.loadInAndOutsToDB() which, basically, loads the
data from the SPARQL Endpoint (this works fine), createOutputInputPairs
(something that I need to do which also works fine) and processInputs.

In processInputs() basically, I get the inputs from the database, I have
the inputs from the SPARQL Endpoint, and using Set theory I made the
difference, to see which inputs I should insert in the database. This works
fine, but, when I try to insert the inputs in the database (using
DerbyDBManager.insertInputs() it seems that is not working.

Basically, I insert using this code:

        public void insertInputs(Set<Input> ri) throws Exception {
                PreparedStatement psInsert = null;
                Iterator<Input> it = ri.iterator();
                while (it.hasNext()) {
                        Input in = it.next();
                        psInsert = conn
                                        .prepareStatement("insert into
inputs(input_class,api) values (?, ?)");
                        psInsert.setString(1, in.getObject());
                        psInsert.setString(2, Constants.APIS[this.api]);
                        this.logger.log("Inserting input in db: " +
in.getObject() + " - API[" + Constants.APIS[this.api] + "]");
                        psInsert.executeUpdate();
                        psInsert.close();
                }

        }

It is supposed that in the following execution of my program, when I made
the select statement to see the inputs in the database, it should give me
results, but.. no results are provided. I attach you the first two
executions of my program:

First (database not created): http://pastebin.com/1k7R8Yup
Second (database created. It is supposed that inputs table should contain
data): http://pastebin.com/yzsK1q9w

So.. as far as I understand, something is wrong in the "insert" but.. I
don't know what.

I hope someone can help me.

Thanks!

-- 
Dr. Alejandro Rodríguez González - PhD

Bioinformatics at Centre for Plant Biotechnology and Genomics UPM-INIA
Polytechnic University of Madrid
http://www.alejandrorg.com
Phone: +34 914524900 . Ext: 25550


*Once the game is over, the king and the pawn go back in the same box. -
Italian proverb*

Reply via email to