This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 106047 - Java DB create table in SQL Editor does not show up in explorer unless you explicitly specify the schema
Summary: Java DB create table in SQL Editor does not show up in explorer unless you ex...
Status: NEW
Alias: None
Product: db
Classification: Unclassified
Component: Code (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Libor Fischmeistr
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-06-07 17:30 UTC by David Vancouvering
Modified: 2013-09-04 08:23 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Vancouvering 2007-06-07 17:30:39 UTC
To reproduce, create a connection to Java DB

jdbc:derby://localhost:1527/testdb;create=true

Log in as any old user and password

Right click on connection and choose Execute Command...

Execute:

CREATE TABLE person (id integer NOT NULL,
male_female integer DEFAULT 0,
first_names varchar(50),
surname varchar(50),
partner_id integer DEFAULT 0,
time_stamp timestamp DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT person_pkey PRIMARY KEY (id)
);

Click on TABLES in the DB Explorer and choose "Refresh".  The table does not
show up.  This is true even if you disconnect and reconnect to the database. 
This is true even if you quote the identifiers, or even upper-case and quote the
identifiers.

However, if you modify the command to be "CREATE TABLE app.person ..."
then it works fine.

You should not have to specify the schema for DB explorer to display the table.
Comment 1 Andrei Badea 2007-06-07 21:42:37 UTC
When you connect as user foo, Java DB sets the default schema to FOO. However,
that schema doesn't exist yet, so you connect to the APP schema -- or any other
one. When you create a table specifying an unqualified table name, that table is
created in the default schema (which gets created at that point). So you get a
table named FOO.PERSON, but the DB Explorer shows the tables in the APP schema.

I don't see what could DB Explorer do here, it looks more like an user error to
me. IIRC this is the reason the user name of the sample database is app. Also
note that you don't encounter this issue if you create the database using Tools
- Java DB Database - Create Database. Suggest closing as invalid.

BTW please do not use "current" as the version, use whichever version you
encountered the issue in or the version currently in development (6.0). Also
note db/dbschema is for dbschema issues only, but dbschema is not used in DB
Explorer.
Comment 2 David Vancouvering 2007-06-07 22:20:26 UTC
I don't understand how we could call this "user error" when it is just a basic
thing that anyone would do.  We are here to make life easier for the user, not
to expect them to know the intricacies of Derby schema management.  As you can
see on the nbusers thread that initiated this bug, it caused a lot of confusion
for both the user and myself (as a newbie to the DB explorer).

I think it's a bit of silliness that Derby would log you in to a schema that
doesn't exist.  But we have to deal with that and try to be as helpful as we can.

I don't see how it can be seen as reasonable for DB explorer to display the APP
schema when the user currently logged in has 'FOO' as their default schema.  At
a minimum DB explorer should show the tables for the default schema of the user.
 Better yet, it should show tables for all the schemas (with a possible ability
to let the user filter out certain schemas they don't care about).

Finally, I don't think we should expect all users to create tables using our
wizard in order to see their tables in the explorer.  Many many users have and
maintain SQL scripts to create tables.

This bug should NOT be closed as invalid unless we can reach some kind of
consensus here.  So far I am not convinced.

I changed the version, sorry about that.  

Subcomponents continue to baffle me.  Saying that explorer doesn't use dbschema
to obtain the schema is un-obvious.  I was also told that 'databinding' is an
invalid component for issues around binding databases to visual components. 
This all reminds me of a scene in a Jack Aubrey novel where all the sailors are
laughing at a landlubber saying 'oi, this guy thought that there should be guns
on the gun deck.  har har har!"
Comment 3 Andrei Badea 2007-06-07 22:51:48 UTC
Yes, displaying all schemas is something we should consider, other tools do it.
I wondered why we don't do it the first time I saw the DB Explorer, but I guess
I just got used to it. Anyway, seems you have some ideas on how to address this.
Comment 4 David Vancouvering 2007-06-30 01:01:12 UTC
Showing other schemas sounds like a fairly hefty UI change, I'm thinking this probably can't go in after feature freeze.
 Any other opinions on this?
Comment 5 Andrei Badea 2007-07-02 12:38:11 UTC
Switching to enhancement for the following reasons.

> I don't see how it can be seen as reasonable for DB explorer to display the
> APP schema when the user currently logged in has 'FOO' as their default
> schema.

The user chooses the schema when registering the connection. In this case the user chose the APP schema, so that's what
the DB Explorer displays.  

> At a minimum DB explorer should show the tables for the default schema of the
> user.

Agreed, but it's not that trivial, probably not doable at all without a Connection.getDefaultSchema() method. I recall
sending Lance a mail about it some time ago.

> Finally, I don't think we should expect all users to create tables using our
> wizard in order to see their tables in the explorer.

I didn't suggest that. I said that you didn't encounter the issue if you used the NB support to create the *database*,
not the tables.
Comment 6 David Vancouvering 2007-10-09 01:05:48 UTC
Switching to enhancement - show all schemas 
Comment 7 Jiri Rechtacek 2009-10-16 14:03:51 UTC
Reassigned to new owner.