简体   繁体   中英

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.

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();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM