NetBeans Forums

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

Building and embedded Derby CRUD application?

 
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Platform Users
View previous topic :: View next topic  
Author Message
cnoevil



Joined: 08 Feb 2010
Posts: 9

PostPosted: Tue Aug 24, 2010 6:06 pm    Post subject: Building and embedded Derby CRUD application? Reply with quote

Greetings Netbeaners,

I'm working on learning the netbeans application platform and I am database noob at the same time. Yikes!...please don't leave already. I want to try and build a small basic CRUD app using Derby (JavaDB...whatever?) in embedded mode with persistence. I've been following this tutorial: http://platform.netbeans.org/tutorials/nbm-crud.html. Well, kinda....

Actually, rather than create a module from the database connection which gives me a connection to the DriverClient jar I want to go "truly" embedded and utilize Derby.jar in my application. Consequently, I have strayed from the well beaten path of the tutorial and now have myself completely confused. I think the bulk of my confusion comes from lacking a firm understanding of the actual structure of a database system AND the actual structure of a Netbeans Platform Application distributable. I basically want to be able to wrap Derby in a module and run it from there within my application and save my database files in a directory within the directory structure of where my application resides.

I'm trying to avoid connection through localhost and just connect to my databases from Derby through the local file structure. Somethng like:
Code:

-MyAppDirectory
     -MyNBPlatformAppDir
          -bin
          -modules
          -myDatabaseFilesDir


Or somethng similar to this in the manner that the Netbeans IDE does with it's application file structure. I know I will have to wrangle a way to copy the test databases' data to the databasefiles directory in order to have any test data to play with, but that's OK. How do I accomplish this?


Thanks,
Mark
Back to top
Javier.Ortiz
Posted via mailing list.





PostPosted: Tue Aug 24, 2010 8:32 pm    Post subject: [platform-dev] Re: Building and embedded Derby CRUD application? Reply with quote

In the module's root folder create a folder named release and drop the database file in there. Then you can retrive it like this as a file:

InstalledFileLocator.getDefault().locate("<file name>", "<module code-name-base from its project.xml>", false);

From the File you can extract the path needed to build the URL to connect to it.

Javier A. Ortiz Bultr
Back to top
cnoevil



Joined: 08 Feb 2010
Posts: 9

PostPosted: Wed Aug 25, 2010 3:40 am    Post subject: Reply with quote

Thank you Javier.

" In the module's root folder create a folder named release and drop the database file in there. "

So, would that be the folder where the database's module jar is located? I built an nbm that wraps the Derby.jar file only and was going to access it from the other modules in my Netbeans Platform Application. Looking at the file view in the IDE shows that I already have a directory named "release" which contains "ext" and then Derby.jar.

Another question comes to mind as well. I already have create my persistence unit from the Customer table of the demo database. In the persistence.xml file it registers the db connection url through localhost to the DerbyClient Driver. Can I just edit the jdbc url string in the xml file to access the embedded driver in the Derby.jar wrapper module to the new location? If so, what would that url string be?

I really appreciate the help. I'm excited that maybe I will actually get this going. I've been reading this stuff quite some time and I feel like I'm getting pretty close to being able to understand what I'm doing... I feel like the Ahaaa! moment must be just around the corner. Laughing
Back to top
Javier.Ortiz
Posted via mailing list.





PostPosted: Wed Aug 25, 2010 9:37 pm    Post subject: [platform-dev] Re: Building and embedded Derby CRUD application? Reply with quote

You asked for a place to copy a pre-made database from. I suggest adding it to the module that needs the database. Leave the wrapped library alone.

You can do that as well. Here are some examples: http://db.apache.org/derby/docs/10.5/devguide/rdevdvlp22102.html

That should get your Ahaaa! moment...

Javier A. Ortiz Bultr
Back to top
cnoevil



Joined: 08 Feb 2010
Posts: 9

PostPosted: Thu Aug 26, 2010 11:46 pm    Post subject: Reply with quote

Thank you Javier. That was helpful, but as usual, my woes seem to spread out in all directions. I think I'm having a hard time getting a grasp of the Netbeans Platform Application structure and the netbeans way of doing things. I can't seem to get my tutorials and test applications to run outside of the IDE. I can build them and run them from the IDE just fine. I go looking for the jar file in the release folder and can't find anything that is runnable and I try to create a zip distibutable so that I can pull the jar file out of that and try running it and it won't compile.

It's obvious that I don't understand the way the IDE works and the launch mechanics of the netbeans platform and digging through the available documentation I'm having a hard time finding anything that spells it out in a simple enough manner that it makes sense to me. Indeed, all the tutorials hardly seem to address the executable structure and launch specifics as though it were just understood, which seems odd to me because if we need someone to explain the basics of the netbeans platform to us then we probably need someone to tell us how to get it to launch outside of the ide as well since it doesn't seem abundantly intuitive.

None the less, thank you for the samples, they were very helpful from the database system point of view.
Back to top
javydreamercsw



Joined: 22 Jun 2009
Posts: 456

PostPosted: Fri Aug 27, 2010 12:53 am    Post subject: [platform-dev] Re: Building and embedded Derby CRUD application? Reply with quote

Maybe you wanted to chew more than you could bite at once. Now that you feel better with database, follow learning here: http://netbeans.org/kb/trails/platform.html
Back to top
cnoevil



Joined: 08 Feb 2010
Posts: 9

PostPosted: Fri Aug 27, 2010 1:48 am    Post subject: Reply with quote

I'm always chewing hard. My reach inevitable exceeds my grasp. I have been going through the learning trail, but I'm not finding everything there that I need, atleast not yet. I have been doing well with simple java apps, compiling, creating executable jar files, working with basic and moderately complex web apps, so I thought I was atleast somewhat ready for working with the netbeans platform and databases.

Anyway, it's not like I have any intention of giving up. I've been in over my head ever since I started this adventure.
Back to top
Javier.Ortiz
Posted via mailing list.





PostPosted: Fri Aug 27, 2010 5:00 pm    Post subject: [platform-dev] Re: Building and embedded Derby CRUD application? Reply with quote

I started my journey some months ago and now I'm lead of UML plugin community team! Feel free to make any questions you have, there's always a helping hand in this list! Don't give up!

Javier A. Ortiz Bultr
Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Platform 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