NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

Re: Embedded Java DB with Application

 
Post new topic   Reply to topic    NetBeans Forums -> Java EE Users
View previous topic :: View next topic  
Author Message
Wade Chandler
Posted via mailing list.





PostPosted: Sun Nov 09, 2008 3:16 am    Post subject: Re: Embedded Java DB with Application Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> Java EE Users All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo