Hi Jason,

I am glad you figured it out - Problems that solve themselve are my
favorite ones :-)
I just cc'ed the mail to the mailing list so everyone can benefit from
the information.

I still want to point out that the problem is not the opening of the
database, but the way you do it. You did use the local way and the local
database access and client/server way are not synchronized, so you run
into this error.

Instead the content of your openDB() function you could have initialized
your session before and then executed:

    session.execute("Open adsss")

This way, the transaction monitor would be taking care of the
synchronization.

Cheers,
Dirk

On 03/04/14 18:52, Jason Ricles wrote:
> I actually figured it out, when I opened up the database in the open db
> method, I made a lock be put on the database.
> 
> 
> On Thu, Apr 3, 2014 at 12:03 PM, Jason Ricles <
> [email protected]> wrote:
> 
>> Here is the rest of the code minus the import statements. I added some
>> comments as well to help you. Also how can I invoke this parallel through
>> the java program or do I send a command to the server telling it how many
>> parallel to run with the keyword parallel?
>> public class Basex{
>> //where i invoke the context class
>> static Context context = new Context();
>>  static ClientSession session=null;
>> static BaseXServer server = null;
>>  public static void main(String[] args) throws IOException,
>> InterruptedException {
>> System.out.println("Sample of BaseX used with server client:");
>>  Context context = new Context();
>> if(context.databases.listDBs().isEmpty() == true)
>>  {
>>     buildDB();
>> }
>>  else
>> openDB();
>> //where i make the server and the session
>>  BaseXServer server = new BaseXServer();
>> session = new ClientSession(context, "admin", "admin");
>>  queryDB(server);
>> System.out.print("program exit and clean up\n");
>>  programExit(server);
>> }
>>
>> //builds the database if one does not exist
>>     public static void buildDB() throws BaseXException
>>     {
>>     System.out.println("Creating a database and populating");
>>     new CreateDB("adsss").execute(context);
>>     new Add("adsss","/home/jricles/Desktop/adss.xml").execute(context);
>>     new Optimize().execute(context);
>>     }
>>
>>
>>
>>     public static void programExit(BaseXServer server) throws IOException
>>     {
>> context.closeDB();
>>  context.close();
>> server.stop();
>> session.close();
>>     }
>>
>> //opens the database so that it may be queried
>>     public static void openDB() throws IOException
>>     {
>>     String db = new Open("adsss").execute(context);
>>     }
>>
>> //queries the database on the server
>>     public static void queryDB(BaseXServer server) throws IOException,
>> InterruptedException
>>     {
>>     try
>>     {
>>      session.setOutputStream(System.out);
>>     session.execute("XQUERY doc('/home/jricles/Desktop/adsss.xml')");
>>      session.query("doc('adsss')/*").execute();
>>     System.out.println();
>>     }
>>     catch(IOException e)
>>     {
>>     System.out.println("clean exit");
>>     System.out.println(e);
>>     server.stop();
>>     System.exit(0);
>>     }
>>     }
>> }
>>
>> On Thu, Apr 3, 2014 at 11:48 AM, Dirk Kirsten <[email protected]> wrote:
>>
>>> Hello Jason,
>>>
>>> this class exist, but it is a testing class, so it is not included in
>>> the jar file. See here for the source code of the class:
>>>
>>> https://github.com/BaseXdb/basex/blob/master/basex-core/src/test/java/org/basex/server/LockingTest.java
>>>
>>> I guess the OverlappingFileLockException should not occur. Do you do
>>> anything besides that code snippet, like executing other quires as well
>>> in parallel. Are you properly using the same context for this?
>>> A small SSCCE might help to reproduce this.
>>> Maybe you can also set PARALLEL (see
>>> https://docs.basex.org/wiki/Options#PARALLEL) to 1.
>>>
>>> Cheers,
>>> Dirk
>>>
>>> On 03/04/14 16:24, Jason Ricles wrote:
>>>> To whom it may concern,
>>>>
>>>> I am trying to see what stuff I can do with the server class and keep
>>>> running into a org.basex.core.BaseXException:
>>>> java.nio.channels.OverlappingFileLockException error. With the following
>>>> code
>>>>
>>>> session.setOutputStream(System.out);
>>>> session.execute("XQUERY doc('/home/jricles/Desktop/adsss.xml')");
>>>> session.query("doc('adsss')/*").execute();
>>>> System.out.println();
>>>>
>>>> To figure out the problem and correct it through trial and error to
>>> learn
>>>> how to use BaseX in java better, I am trying to use the following class
>>>> from the import server.* statement I imported at the beginning of the
>>> code
>>>> http://docs.basex.org/javadoc/org/basex/server/LockingTest.html.
>>> However it
>>>> gives me an error that this class does not exist in the Server import.
>>> I am
>>>> curious if this javadoc is out of date, or if it is incorrect in
>>> something
>>>> that I might be doing in my code.
>>>>
>>>> Thanks,
>>>>
>>>> Jason Ricles
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> BaseX-Talk mailing list
>>>> [email protected]
>>>> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
>>>>
>>>
>>> --
>>> Dirk Kirsten, BaseX GmbH, http://basex.org
>>> |-- Firmensitz: Blarerstrasse 56, 78462 Konstanz
>>> |-- Registergericht Freiburg, HRB: 708285, Geschäftsführer:
>>> |   Dr. Christian Grün, Dr. Alexander Holupirek, Michael Seiferle
>>> `-- Phone: 0049 7531 28 28 676, Fax: 0049 7531 20 05 22
>>>
>>
>>
> 

-- 
Dirk Kirsten, BaseX GmbH, http://basex.org
|-- Firmensitz: Blarerstrasse 56, 78462 Konstanz
|-- Registergericht Freiburg, HRB: 708285, Geschäftsführer:
|   Dr. Christian Grün, Dr. Alexander Holupirek, Michael Seiferle
`-- Phone: 0049 7531 28 28 676, Fax: 0049 7531 20 05 22
_______________________________________________
BaseX-Talk mailing list
[email protected]
https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk

Reply via email to