Rentonie
Rentonie

Reputation: 477

Parallel use of Embedded Derby Database

I have a project which consists of two parts.

First part is an API that answers to various request and sometimes has to check the database. The database itself is an embedded Derby DB.

Later, i noticed that i needed a separate program to scan a directory and update the database accordingly. I made one using quartz scheduler and it works perfectly.

The problem arises when both of these come in to play together. If one has booted the database first, the other one is unable to operate.

The clash between the two programs is narrowed down to one particular table. The API just reads it, while the other one updates it. There are no other conflicts.

Kindly suggest how can i work this problem around. Note that these are two seperate Maven projects.

Upvotes: 1

Views: 248

Answers (1)

Rentonie
Rentonie

Reputation: 477

I followed the guide seen here http://db.apache.org/derby/docs/10.10/adminguide/radminembeddedserverex.html

Essentially i added these lines in my API

import org.apache.derby.drda.NetworkServerControl;
import java.net.InetAddress;

(...)
NetworkServerControl server = new NetworkServerControl
(InetAddress.getByName("localhost"),1527);
server.start(null);

And connected via the other with this

 String nsURL="jdbc:derby://localhost:1527/DatabaseName";  
java.util.Properties props = new java.util.Properties();

Upvotes: 2

Related Questions