The actual sites asigned by NB6.5 for DB files when using Embedded Java DB

View: New views
6 Messages — Rating Filter:   Alert me  

The actual sites asigned by NB6.5 for DB files when using Embedded Java DB

by JulioSergio :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I was trying to test the Java DB (Embedded) Driver. So, I created a Database within NB6.5: In the "Services" tab I expanded the Databases node. Then I right clicked the "Java DB (Embedded)" node, and I was able to create my Database. I could also define some tables for it. All this structure was created in a "standard" location, namely:
/home/<me>/.netbeans/<net-beans-version>/derby/<Database-Name>/

Then I aimed at programing some Java code to manipulate my Database, with the aid of NB.  I followed the instructions given for "Creating the Application" in the tutorial http://www.netbeans.org/kb/60/java/gui-db.html, and apparently the application runs.
However, I discovered  that NB decided that the site for the Database was a completely different one. It created a new Database mimicking the structure of the mine, in this other site:
/home/<me>/NetBeansProjects/<MyProjectName>/<Database-Name>
Furthermore, every time I run the application, it comes to me with the following message:

  run:
  [TopLink Info]: 2008.08.22 05:31:17.688--ServerSession(15674464)--TopLink, version: Oracle TopLink Essentials - 2.0.1
  (Build b09d-fcs (12/06/2007))
  [TopLink Info]: 2008.08.22 05:31:30.464--ServerSession(15674464)--file:/home/checo/NetBeansProjects/EditaMetaInfo
  /src/-jdbc:derby:LearningDBPU login successful
  [TopLink Warning]: 2008.08.22 05:31:32.506--ServerSession(15674464)--Exception [TOPLINK-4002] (Oracle TopLink
  Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.DatabaseException
  Internal Exception: java.sql.SQLException: Table/View 'METAINFO' ya existe en Schema 'APP'.
  Error Code: 30000
  Call: CREATE TABLE APP.METAINFO (ID INTEGER NOT NULL, ATRIBUTO VARCHAR(20), VALOR
  VARCHAR(80), PRIMARY KEY (ID))
  Query: DataModifyQuery()

though it runs, I understand that it is trying to create the table again and again.
My question is, what if I want to create different projects to perform different operations on the same Database? How could this be done in NB?
Does anybody can help me with this?

Re: The actual sites asigned by NB6.5 for DB files when using Embedded Java DB

by JulioSergio :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Well, nobody tried to answer this message, but in the meantime I investigated the subject.

Derby or Java DB has an environment variable that defines the place where the Databases are located. When you run your Java program, you ought to tell the JVM of such place in the following way:

java  -Dderby.system.home=<your-Derby-directory>  -jar <your-jar-program>

To tell the IDE about this place, on the Projects tab, right click on your projects node and select 'Properties'. There, select the 'Run' category, and in the text field labelled as 'VM Options' write:

-Dderby.system.home=<your-Derby-directory>

and that's it.

Best regards,

Sergio.

JulioSergio wrote:
I was trying to test the Java DB (Embedded) Driver. So, I created a Database within NB6.5: In the "Services" tab I expanded the Databases node. Then I right clicked the "Java DB (Embedded)" node, and I was able to create my Database. I could also define some tables for it. All this structure was created in a "standard" location, namely:
/home/<me>/.netbeans/<net-beans-version>/derby/<Database-Name>/

Then I aimed at programing some Java code to manipulate my Database, with the aid of NB.  I followed the instructions given for "Creating the Application" in the tutorial http://www.netbeans.org/kb/60/java/gui-db.html, and apparently the application runs.
However, I discovered  that NB decided that the site for the Database was a completely different one. It created a new Database mimicking the structure of the mine, in this other site:
/home/<me>/NetBeansProjects/<MyProjectName>/<Database-Name>
Furthermore, every time I run the application, it comes to me with the following message:

  run:
  [TopLink Info]: 2008.08.22 05:31:17.688--ServerSession(15674464)--TopLink, version: Oracle TopLink Essentials - 2.0.1
  (Build b09d-fcs (12/06/2007))
  [TopLink Info]: 2008.08.22 05:31:30.464--ServerSession(15674464)--file:/home/checo/NetBeansProjects/EditaMetaInfo
  /src/-jdbc:derby:LearningDBPU login successful
  [TopLink Warning]: 2008.08.22 05:31:32.506--ServerSession(15674464)--Exception [TOPLINK-4002] (Oracle TopLink
  Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.DatabaseException
  Internal Exception: java.sql.SQLException: Table/View 'METAINFO' ya existe en Schema 'APP'.
  Error Code: 30000
  Call: CREATE TABLE APP.METAINFO (ID INTEGER NOT NULL, ATRIBUTO VARCHAR(20), VALOR
  VARCHAR(80), PRIMARY KEY (ID))
  Query: DataModifyQuery()

though it runs, I understand that it is trying to create the table again and again.
My question is, what if I want to create different projects to perform different operations on the same Database? How could this be done in NB?
Does anybody can help me with this?

Re: The actual sites asigned by NB6.5 for DB files when using Embedded Java DB

by Johnny Kewl :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


----- Original Message -----
From: "JulioSergio" <juliosergio@...>
To: <nbusers@...>
Sent: Monday, September 01, 2008 8:41 PM
Subject: Re: [nbusers] The actual sites asigned by NB6.5 for DB files when
using Embedded Java DB


>
> Well, nobody tried to answer this message, but in the meantime I
> investigated
> the subject.
>
> Derby or Java DB has an environment variable that defines the place where
> the Databases are located. When you run your Java program, you ought to
> tell
> the JVM of such place in the following way:
>
> java  -Dderby.system.home=<your-Derby-directory>  -jar <your-jar-program>
>
> To tell the IDE about this place, on the Projects tab, right click on your
> projects node and select 'Properties'. There, select the 'Run' category,
> and
> in the text field labelled as 'VM Options' write:
>
> -Dderby.system.home=<your-Derby-directory>
>
> and that's it.
>
> Best regards,
>
> Sergio.

Sergio, no... you making an embedded dB, you dont really want the user to
have to set command lines, better if they can just click on the jar.

The actual location of the dB is determined by this...

Derby connection URI
jdbc:derby:" + dbLocation + ";create=true"

if you dont set it... it defaults to ./
or
Dderby.system.home

Then for the actual Jar...
just include derby.jar in the lib of your project... it will be packaged to
go.

What you doing now is giving the user a choice of setting it... and if they
dont... it will be created in ./
which could be anywhere later...

We normally place them in the /user folder on a machine... and set it in the
URI... user does nothing ;)


java  -Dderby.system.home=<your-Derby-directory>  -jar <your-jar-program>
means the user has to type it or make a sh/bat file

java  -jar <your-jar-program>

means the user can just double click on the jar... on windows anyway... if
you see what I'm trying to show you ;)

Possibly JPA (we dont use it on little apps) wants it (URI) set in some
xml... if so thats the real problem.
It must have a way to set the URI from code...

Thats the problem with frameworks designed for EJB... they tend to make the
simple complex on a small app ;)
Its the reason we dont like the new dB wizards... ie you struggling because
of JPA.. not because of derby and JDBC...

Have fun...

---------------------------------------------------------------------------
HARBOR : http://www.kewlstuff.co.za/index.htm
The most powerful application server on earth.
The only real POJO Application Server.
See it in Action : http://www.kewlstuff.co.za/cd_tut_swf/whatisejb1.htm
---------------------------------------------------------------------------




Re: The actual sites asigned by NB6.5 for DB files when using Embedded Java DB

by JulioSergio :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thank you Johnny. You're right.
Although I had seen the Derby connection URI that includes the dbLocation (that is: "jdbc:derby:" + dbLocation + ";create=true") before, I had missed out the point you are remarking: that this form is simpler and more convenient for the user.

Sergio.


Johnny Kewl wrote:
----- Original Message -----
From: "JulioSergio" <juliosergio@gmail.com>
To: <nbusers@netbeans.org>
Sent: Monday, September 01, 2008 8:41 PM
Subject: Re: [nbusers] The actual sites asigned by NB6.5 for DB files when
using Embedded Java DB



Sergio, no... you making an embedded dB, you dont really want the user to
have to set command lines, better if they can just click on the jar.

The actual location of the dB is determined by this...

Derby connection URI
jdbc:derby:" + dbLocation + ";create=true"

if you dont set it... it defaults to ./
or
Dderby.system.home

Then for the actual Jar...
just include derby.jar in the lib of your project... it will be packaged to
go.

What you doing now is giving the user a choice of setting it... and if they
dont... it will be created in ./
which could be anywhere later...

We normally place them in the /user folder on a machine... and set it in the
URI... user does nothing ;)


java  -Dderby.system.home=<your-Derby-directory>  -jar <your-jar-program>
means the user has to type it or make a sh/bat file

java  -jar <your-jar-program>

means the user can just double click on the jar... on windows anyway... if
you see what I'm trying to show you ;)

Possibly JPA (we dont use it on little apps) wants it (URI) set in some
xml... if so thats the real problem.
It must have a way to set the URI from code...

Thats the problem with frameworks designed for EJB... they tend to make the
simple complex on a small app ;)
Its the reason we dont like the new dB wizards... ie you struggling because
of JPA.. not because of derby and JDBC...

Have fun...

---------------------------------------------------------------------------
HARBOR : http://www.kewlstuff.co.za/index.htm
The most powerful application server on earth.
The only real POJO Application Server.
See it in Action : http://www.kewlstuff.co.za/cd_tut_swf/whatisejb1.htm
---------------------------------------------------------------------------



Re: The actual sites asigned by NB6.5 for DB files when using Embedded Java DB

by David Van Couvering-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Just to clarify, the default location isn't really "." but the
standard JVM system property "user.dir".  This is overriden by the
Derby-specific system property "derby.system.home" if it is set.

David

On Mon, Sep 1, 2008 at 3:26 PM, JulioSergio <juliosergio@...> wrote:

>
> Thank you Johnny. You're right.
> Although I had seen the Derby connection URI that includes the dbLocation
> (that is: "jdbc:derby:" + dbLocation + ";create=true") before, I had missed
> out the point you are remarking: that this form is simpler and more
> convenient for the user.
>
> Sergio.
>
>
>
> Johnny Kewl wrote:
>>
>>
>> ----- Original Message -----
>> From: "JulioSergio" <juliosergio@...>
>> To: <nbusers@...>
>> Sent: Monday, September 01, 2008 8:41 PM
>> Subject: Re: [nbusers] The actual sites asigned by NB6.5 for DB files when
>> using Embedded Java DB
>>
>>
>>
>> Sergio, no... you making an embedded dB, you dont really want the user to
>> have to set command lines, better if they can just click on the jar.
>>
>> The actual location of the dB is determined by this...
>>
>> Derby connection URI
>> jdbc:derby:" + dbLocation + ";create=true"
>>
>> if you dont set it... it defaults to ./
>> or
>> Dderby.system.home
>>
>> Then for the actual Jar...
>> just include derby.jar in the lib of your project... it will be packaged
>> to
>> go.
>>
>> What you doing now is giving the user a choice of setting it... and if
>> they
>> dont... it will be created in ./
>> which could be anywhere later...
>>
>> We normally place them in the /user folder on a machine... and set it in
>> the
>> URI... user does nothing ;)
>>
>>
>> java  -Dderby.system.home=<your-Derby-directory>  -jar <your-jar-program>
>> means the user has to type it or make a sh/bat file
>>
>> java  -jar <your-jar-program>
>>
>> means the user can just double click on the jar... on windows anyway... if
>> you see what I'm trying to show you ;)
>>
>> Possibly JPA (we dont use it on little apps) wants it (URI) set in some
>> xml... if so thats the real problem.
>> It must have a way to set the URI from code...
>>
>> Thats the problem with frameworks designed for EJB... they tend to make
>> the
>> simple complex on a small app ;)
>> Its the reason we dont like the new dB wizards... ie you struggling
>> because
>> of JPA.. not because of derby and JDBC...
>>
>> Have fun...
>>
>> ---------------------------------------------------------------------------
>> HARBOR : http://www.kewlstuff.co.za/index.htm
>> The most powerful application server on earth.
>> The only real POJO Application Server.
>> See it in Action : http://www.kewlstuff.co.za/cd_tut_swf/whatisejb1.htm
>> ---------------------------------------------------------------------------
>>
>>
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/The-actual-sites-asigned-by-NB6.5-for-DB-files-when-using-Embedded-Java-DB-tp19117012p19261567.html
> Sent from the Netbeans - Users mailing list archive at Nabble.com.
>
>



--
David W. Van Couvering
http://davidvancouvering.blogspot.com

Re: The actual sites asigned by NB6.5 for DB files when using Embedded Java DB

by Rodgy :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I have the same issue of the IDE looking at the template of the database and when running the application within the IDE a local copy being generated (and updated correctly etc). I can't see the data from the database explorer in the IDE as it looks at the template, not the local data. Also using the iReport add-in within the IDE the same occurs. I got around that by using SquirrelSQL and a standalone copy of iReport (which i feel shouldn't really be necessary), but when I put my Jasper report on a button in my app and then run it within the IDE I get no data. The database URL in all cases is just "jdbc:derby:" + mydatabasename etc ie no path etc - am I getting this wrong? Where does this need to be entered in the IDE for all references to look at this copy of the database?


On Mon, Sep 1, 2008 at 3:26 PM, JulioSergio <juliosergio@gmail.com> wrote:
>
> Thank you Johnny. You're right.
> Although I had seen the Derby connection URI that includes the dbLocation
> (that is: "jdbc:derby:" + dbLocation + ";create=true") before, I had missed
> out the point you are remarking: that this form is simpler and more
> convenient for the user.
>
> Sergio.
>
>
LightInTheBox - Buy quality products at wholesale price!