You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Nicolas Nobelis <ni...@gmail.com> on 2012/03/23 17:46:03 UTC

Checking is directory is valid TDB

Hello all,


I'm currently writing a graphical app that allows the user to connect to a
TDB and run Sparql queries against it.

So, the user chooses a directory and then I call
TDBFactory.createDataset(String dir) to connect to it.

My problem is that this method creates the TDB if the directory is empty
(this is said in the Javadoc "Create or connect to a TDB-backed dataset").

I would prefer a method that only tries to connect to the TDB, and throws
an exception if no valid TDB has been found in this directory. Does such a
method exist ? I'll looked in the TDB Javadoc but I didn't find any...

Thanks by advance !

Nicolas Nobelis

Re: Checking is directory is valid TDB

Posted by Nicolas Nobelis <ni...@gmail.com>.
Yes, I was afraid this solution was the only way of checking TDB existence.

Thanks for the answer !

Nicolas

On 26 March 2012 16:43, Andy Seaborne <an...@apache.org> wrote:

> On 23/03/12 16:46, Nicolas Nobelis wrote:
>
>> Hello all,
>>
>>
>> I'm currently writing a graphical app that allows the user to connect to a
>> TDB and run Sparql queries against it.
>>
>> So, the user chooses a directory and then I call
>> TDBFactory.createDataset(**String dir) to connect to it.
>>
>> My problem is that this method creates the TDB if the directory is empty
>> (this is said in the Javadoc "Create or connect to a TDB-backed dataset").
>>
>> I would prefer a method that only tries to connect to the TDB, and throws
>> an exception if no valid TDB has been found in this directory. Does such a
>> method exist ? I'll looked in the TDB Javadoc but I didn't find any...
>>
>
> There's no such method in TDB but you can write a small code segment that
> tests for whether the directory exists and whether some key file (such as
> "nodes.dat") exists.
>
>        Andy
>

Re: Checking is directory is valid TDB

Posted by Andy Seaborne <an...@apache.org>.
On 23/03/12 16:46, Nicolas Nobelis wrote:
> Hello all,
>
>
> I'm currently writing a graphical app that allows the user to connect to a
> TDB and run Sparql queries against it.
>
> So, the user chooses a directory and then I call
> TDBFactory.createDataset(String dir) to connect to it.
>
> My problem is that this method creates the TDB if the directory is empty
> (this is said in the Javadoc "Create or connect to a TDB-backed dataset").
>
> I would prefer a method that only tries to connect to the TDB, and throws
> an exception if no valid TDB has been found in this directory. Does such a
> method exist ? I'll looked in the TDB Javadoc but I didn't find any...

There's no such method in TDB but you can write a small code segment 
that tests for whether the directory exists and whether some key file 
(such as "nodes.dat") exists.

	Andy