How to specify relative path for embedded database URL in Data Source Properties?

Hi,

I'm trying to configure a data source in IntelliJ to connect to a local, embedded Derby database.  The database is named "sample-db" and is located within my IDEA project.  I'm trying to create the datasource because I want to take advantage of IDEA's great database integration to give me warnings and such when writing SQL queries.  It's not the actual database created and used by my app, but rather just a clone so that I can configure the datasource.  Anyway...

In the "Database" tab of the Data Source Properties window, I've pointed the JDBC driver files at the derby.jar, and have specified the JDBC driver class to be org.apache.derby.jdbc.EmbeddedDrive.  And I can get it all to work just fine if I specify an absolute path for the database URL.  For example:

jdbc:derby:/Users/chris/Documents/Work/Projects/MyProject/etc/sample-db

But, that's less than ideal since that path gets saved in the .ipr file and makes my project un-shareable with others.  Similarly, it works if I jar up the database directory and specify a jar in the database URL:

jdbc:derby:jar:(/Users/chris/Documents/Work/Projects/MyProject/etc/sample-db.jar)sample-db

Same problem, though.  I really want to be able to use a path relative to the project or module.  However, no amount of trying $PROJECT_DIR$, ${PROJECT_DIR}, $MODULE_DIR$, ${MODULE_DIR} or relative paths like this make any difference--they all fail when I try Test Connection:

jdbc:derby:etc/sample-db

jdbc:derby:./etc/sample-db

jdbc:derby:$PROJECT_DIR$/etc/sample-db

jdbc:derby:directory:etc/sample-db

And so on.  Is it possible to use a relative URL?  If so, how?

thanks!

Chris

Mac OS 10.8.2, IntelliJ IDEA IU-128.18, Apache Derby 10.9.1.0

2 comments

There's no such option currently.
I think $PROJECT_DIR$ is a good solution. Please file a YouTrack ticket. We'll try to get it into the ucpoming 12.1 release.

0

Excellent!  Thanks so much, that will be a huge help.  Filed as IDEA-102603.

0

Please sign in to leave a comment.