db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Van Couvering" <da...@vancouvering.com>
Subject Re: Embedded Derby - How to change the schema?
Date Thu, 04 Oct 2007 23:01:39 GMT
Well, this sounds nasty.

In NetBeans 6, I did the following with an embedded connection (sorry, I'm
not such a master with screen shots):

- Connected to the TRAVEL database, with the TRAVEL schema
- Executed 'CREATE SCHEMA foo;'
- Disconnected
- Clicked Connect and got the dialog, then chose Advanced, and then pressed
[Get Schemas], and 'FOO' was on the list of available schemas

So it works in NetBeans 6

Now, in NetBeans 5.5.1, I did the same thing, and it worked for me.

So, we can conclude a couple of things:

- You are connected to a different database, even though you think it's the
same one.  Wait, I think that may be possible . You seem to be using a
different tool to create your schema and tables.  And when you  use an
embedded connection to Derby, is your URL a full path to the database name,
or a relative path?  If it's a relative path, then the database is created
in the directory where your tool was started, which will likely be
*different* from where NetBeans was started.  When NetBeans is connecting to
the database with the same name, it may actually be a different physical
file on the system, and thus the tables don't show up.

Try making sure your JDBC URL is a *full path* to a database location, e.g.
"jdbc:derby:/this/is/the/path/to/my/db/mydb;create=true" or
"jdbc:derby:c:/path/to/my/db/mydb;create=true" (note you use forward slashes
even for Windows).

- You didn't create the schema (I find that hard to believe)
- You didn't create the tables (ditto)
- You have a different version of NB than I do, one that is broken

I think item 1 is likely the possible choice.

Did you know that you can execute SQL directly in NB?  So if you have SQL
scripts, you can do the following:

-> Connect to your DB
-> Right click and choose "Execute Command..."
-> In the command window, right click and choose "Select in->Files".  This
gives you a file browser. Browse to your SQL file, select it, and it's
dropped into the command window
-> Punch the green arrow to execute the file

This way  you don't have the potential of working with two databases when
you think you have one.

David

On 10/4/07, Daniel Noz <d.noz@gmx.de> wrote:
>
>  David Van Couvering schrieb:
>
> The other problem that can happen is that the tables are created in a
> different schema than the one that is used when you connect with NetBeans.
> Notice that your connection in NB is labeled 'bb on APP'.  That means it's
> using the default schema, APP.
>
> It's possible that your tables were created under a different schema. In
> particular, if you log in as user 'foo' and there is a schema named 'foo' in
> the database, then that schema is used, otherwise 'APP' is used as the
> schema.
>
> NetBeans currently *only* shows tables for the current schema, not for all
> schemas.  There is a feature request (I think) to add support to show all
> schemas.  This comes up pretty regularly.
>
> David
>
> On 10/3/07, Daniel Noz <d.noz@gmx.de> wrote:
> >
> > Dyre.Tjeldvoll@Sun.COM schrieb:
> >
> >  Daniel Noz <d.noz@gmx.de> <d.noz@gmx.de> writes:
> >
> >    Hello derby-users,
> >
> > I develop a richt client application with netbeans using derby-db and
> > toplink as JPA implementation.
> > If i use the embedded driver (see <property name="toplink.jdbc.driver"
> >
> > value="org.apache.derby.jdbc.EmbeddedDriver"/>) it works great to
> > persist Entity-Objects.
> > However i cant see anything within the database, i am using. I can
> > connect, hower i dont see any created tables or data within...? Is
> >
> > this a feature with the embedded driver?
> > I know that my Entity Objects are within the database...if i use the
> > entitymanager to find the persited object..it works great...
> > By the way: I dont use the JavaEE lookup. I create the necessary
> >
> > EntityManager instance like this:
> > EntityManagerFactory factory =
> > Persistence.createEntityManagerFactory("BBTrainerAppPU");
> > EntityManager em = factory.createEntityManager();
> >
> > Can anyone help me and tell me if this is a feature or how to find the
> >
> > created table or data within?
> >
> >  Could it be that you have two different databases with the same name
> > in different locations?
> >
> > A similar situation was discussed here a while back. See
> >
> >
> > http://www.nabble.com/Hibernate%3A-table-view-does-not-exist-tf4521125.html
> >
> > HTH
> >
> >
> >
> >  I dont think so...
> > thats what i see within netbeans...
> >
> > and here is my persistance.xml
> >
> >
> > i am meanwhile going to read through the link you sent me...thanks...
> >
> >
>  How can i change the schema within a embedded JAVA DB?
> If i create a new connection with NetBeans
>
> and i click "advanced"
> i have to choose the schema...
>
> but i can select only the schemas:
> APP, SYS; NULLID, SYSCAT....
>
> not the one i created earlier
>
>
> Can anyone help me?
>
> I am getting crazy with this embedded derby problem ....grrrr
>
>

Mime
View raw message