NetBeans Forums
| View previous topic :: View next topic |
| Author |
Message |
Wade Chandler Posted via mailing list.
|
Posted: Sun Nov 09, 2008 3:16 am Post subject: Re: Embedded Java DB with Application |
|
|
I would use something other than the current working path. If users run your application from some other directory than you think etc you may end up with the working directory being some where you didn't expect or code for. Better approaches are to use a defined deployment structure and to have files relative to some of your JAR files. Then you can figure out where your files are no matter what. i.e. You have a lib folder with some JAR file in it, then you can call getResource("/some/package/SomeClass.class") and receive a URL which will be a JAR URL which you can parse to get the JAR file path. From there you can relatively figure out your path and build it dynamically for your database connection.
Wade
==================
Wade Chandler, CCE
Software Engineer and Developer, Certified Forensic Computer Examiner, NetBeans Dream Team Member, and NetBeans Board Member
http://www.certified-computer-examiner.com
http://wiki.netbeans.org/wiki/view/NetBeansDreamTeam
http://www.netbeans.org
From: Grover Blue <address-removed>
To: address-removed
Sent: Saturday, November 8, 2008 2:44:16 PM
Subject: Re: [nbj2ee] Re: Embedded Java DB with Application
yeah, i found documentation on that. what's strange is that you can't provide a relative path to the current working directory. all relative paths are based on the jva db system path. Instead, i'm gonna get the path for the current directory (new File(".")) and use that to dynamically set the path to the embedded DB.
thanks for your response.
On Sat, Nov 8, 2008 at 1:54 PM, Xavier Callejas <address-removed ([email]address-removed[/email])> wrote:
| Quote: | Grover Blue wrote:
| Quote: | I want to write an application that embeds the Java DB with it. I'm
confused as to where the databases are stored during development, and how
to included that DB with the final distribution. I found some text that
shows how to use the embedded Derby driver, but there doesn't seem to be a
way to specify an existing DB jar/file, like I can with SQLite and other
languages. Maybe I'm missing something. Can anyone help clarify this?
|
well, you can define the path of the embedded database in the jdbc url, for
example:
jdbc:derby:/this/is/where/nameOfDB;create=true
You could create inside Netbeans a connection to this database, and use this
connection in your apps. instead of the netbeans default derby db
connection. So if you run your app. outside netbeans it will use the right
database as the url was always constant.
rgds.
|
--
"If the American people ever allow private banks to control the issue of their currency, first by inflation, then by deflation, the banks...will deprive the people of all property until their children wake-up homeless on the continent their fathers conquered... The issuing power should be taken from the banks and restored to the people, to whom it properly belongs." -- Thomas Jefferson
"Government big enough to supply everything...is big enough to take everything you have. The course of history shows that as a government grows, liberty decreases" --- Thomas Jefferson
www.CampaignForLiberty.org |
|
| 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
|
|