Win a copy of Java EE 8 High Performance this week in the Java/Jakarta EE forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Netbeans database sample and Glassfish database sample  RSS feed

Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've installed Netbeans 7.1 IDE with the option to install Glassfish 3.1.1 as well.

So under netbeans I've written a JavaEE web app which writes to database jdbc/sample...and it does....under C:\Documents and Settings\David\.netbeans-derby\ is a folder 'sample'

However it is necessary to copy this folder to D:\Glassfish3\javadb\bin\ in order for glassfish running completely indepent of netbeans to use the sample db.

in short : Netbeans creates, reads and writes a db and it shows up in C:\Documents and Settings\David\.netbeans-derby\
Glassfish reads and writes a db and sees it only in D:\Glassfish3\javadb\bin\

How can I get these two guys to agree on a common place to park the sample database folder??
Dave Elwood
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've found that strange things must be done to make this work.

In Netbeans under the Services tab, you right click on JavaDB and define where the databases are to be sought.

I put in D:\Glassfish3\glassfish\databases -

Before Netbeans does anything with any database, glassfish and then the database server must be turned on and when you turn them on the current directory must be somewhere other than D:\Glassfish3\glassfish\bin where asadmin.bat lies. To turn on glassfish and then the database server I made a batch file with the path to asadmin.bat written out fully :

putting the current directory far away from D:\Glassfish3\glassfish\bin is necessary otherwise the databases will originate in that directory.
putting the current directory on E:\ causes the database creation directory to be D:\Glassfish3\glassfish\databases - don't ask me why.

possibly during previous muck-ups the databases were created in the D:\Glassfish3\glassfish\bin folder and along
with that, a derby.log file and a file. And then in the future, some process was looking for a neat place to
create the database files and since D:\Glassfish3\glassfish\bin is on PATH it looked there, saw derby.log and
and said "this is the place".

So I wipe away ALL derby.log and files.

With both servers up and running I go to the admin console

A. in Resources / JDBC / JDBC connection pools / SamplePool
Under the third tab is 'further properties'
here : URL = jdbc:derby://localhost:1527/newDBName
Save should bring up a green ok

B. then in Resources / JDBC / JDBC Resources
add a new resource jdbc/newDBName
OK should not bring up any message

At this moment a new database folder newDBName appears under the databases folder, if not then
you were in the wrong seat when the plane crashed. Turn off both servers and turn then on again
and make sure that when turning on the database server the current dir is not where the glassfish\bin directory is.

So the new directory in glassfish\databases\newDBName is there.

So now turn both servers off.

Run Netbeans and write the Entity Bean app or modify an existing Entity Bean app (javaee6).
In persistence.xml is the name of the database. change the value to jdbc/newDBName and compile it.
Run it and Netbeans will turn on glassfish and the database server for you and do its job.

Then turn off Netbeans and turn glassfish and the database server on again for normal mortal use.
then localhost:8080/entitybeanapp. should do the job too.

Hope this helps somebody.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!