Get local database project location in script

User 726a4c1c00

16-07-2014 08:24:21

Hello there,


I want to work with files in local database folder but I cannot find a way to get the project directory in groovy script.
Is there a way to get JDBC url? Any other suggestions would be welcome.


Thanks

ChemAxon 2bdd02d1e5

18-07-2014 03:11:54

Hi there!


Yes there is a way. You can copy JDBC URL from Schema configuration settings dialog. To get it r-click to schema node in Porjects window -> Schema Settings...


Connecting to derby DB directly can be done via Database Explorer in IJC (Window -> Other -> Services). Or by any other tool supporting Derby DB. Note that only one connection is allowed at the time. More details can be found in similar forum thread https://www.chemaxon.com/forum/ftopic12949.html


Hope it helps!

User 726a4c1c00

18-07-2014 08:54:54

fzimandl,


thank you, but it's not exactly what I want. I use local database from my work and home by putting it in the Dropbox folder. However the absolute paths to this folder are different in the computers I'm using. Therefore from what you have suggested I would need to either manually change the location of project in the scripts each time or devise code that checks for all possible locations. Either way is clumsy and that's why I'm asking on how to get the open project location through the groovy script.

I have tried all kinds of methods and parameters of DFSchema object, but nothing worked. The closest that I have got to was through:
schema.getSchemaProvider()
which gives me:


[email protected][provider: SP-Cookie[file: /home/user/IJCprojects/SDFanalysis/.config/[email protected]:1ff2b382]]

When I convert the output to string I can get the "file" part, but there are two problems with that:



1. Somehow if I try to get schema provider in schema initiation script ('on_connect' function) it returns null. Whereas the same command in schema close script ('on_disconnect' function) gives me the output above.



2. Regex analysis of this string is not the best way, because there has to be a method to call for either SchemaProvider file, schema connection url, JDBC url, project object or something which I'm not aware of.


It would be very helpful to if anyone could suggest such method.

ChemAxon 2bdd02d1e5

23-07-2014 14:07:00

DMatulis,


I'm sorry to tell, but there is no better way, than you suggested. The schema URL can be only obtained by schema.getSchemaProvider() method and subsequent regex processing of returned result.


Unfortunately there is also the problem that schema init script on_connect does return null.


Filip