NetBeans Forums
| View previous topic :: View next topic |
| Author |
Message |
jbullard
Joined: 11 Jan 2010 Posts: 1
|
Posted: Wed Jan 27, 2010 8:30 pm Post subject: embedded derby database url? |
|
|
I have checked this list and not found an answer to the problem I am
having, but I am sure there is a simple fix.
I'm using Netbeans 6.7, for a java webapp and I am trying to connect to
an embedded derby database. The database exists and is in the
~/.netbeans-derby folder. I can load the driver without any problem.
I can also connect to the database, AS LONG AS I use the fully resolved
pathname to the database:
Connection cxn = null;
cxn =
DriverManager.getConnection("jdbc:derby:/Users/bullard/.netbeansderby/o
pdb");
But this seems to be a bad way to go if I eventually want to deploy
this application on a different server. Every time I try to use a
relative pathname for the url (such as jdbc:derby:opdb), I get an error
at runtime that the database cannot be found.
The other thing that worked was setting the derby.system.home variable
right before I loaded the database driver, like this:
System.setProperty("derby.system.home",
"/Users/bullard/.netbeans-derby");
try {
Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
driverLoaded = true;
} catch (Exception ex) {
ex.printStackTrace();
driverLoaded = false;
}
Then I can use the relative url when I make connections. But again, I
don't like having to hard-code the full pathname.
How can I get around having to make hard-coded reference to a full
pathname? Is this a netbeans issue or a derby issue?
Many thanks in advance. |
|
| Back to top |
|
 |
Franz Posted via mailing list.
|
Posted: Thu Jan 28, 2010 8:07 am Post subject: embedded derby database url? |
|
|
Hello,
Am 27.01.2010 19:57, schrieb address-removed:
| Quote: | I'm using Netbeans 6.7, for a java webapp and I am trying to connect to
an embedded derby database. The database exists and is in the
~/.netbeans-derby folder. I can load the driver without any problem.
I can also connect to the database, AS LONG AS I use the fully resolved
pathname to the database:
|
I don't have my derby project at hand but I think I'm using
The system property user.dir (and possibly a File object's
getAbsolutePath()) to build the absolute path - depending on the current
user.
Maybe that helps
Regards
franz |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|