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 79342 - Need for API for DB creation
Summary: Need for API for DB creation
Status: NEW
Alias: None
Product: db
Classification: Unclassified
Component: Derby (show other bugs)
Version: 5.x
Hardware: All All
: P2 blocker (vote)
Assignee: Libor Fischmeistr
URL:
Keywords:
Depends on:
Blocks: 76543
  Show dependency tree
 
Reported: 2006-06-28 14:55 UTC by Tomasz Slota
Modified: 2013-08-01 12:52 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 Tomasz Slota 2006-06-28 14:55:18 UTC
We need the following methods to be exposed:

// 1st priority
Status createDB(name, user, password)

// 2nd priority
boolean isLegalDBName(name);
String[] getExistingDBNames();
boolean isJavaDBRegistered();

// 3rd priority
File getDBPhisicalLocation();

(Final method/class names are to be defined)

Motivation:

When user creates a new project from a sample template that requires DB access
(such as CustomerCMP sample, see issue #76543) we should create a new database
to be used by the project.

The user will be prompted for DB creation parameters i.e. DB name, user name and
password. The name will be verified for validity and duplication as user types.

Currently existing samples require either a blank DB or DB with the "Sample" schema.

If Java DB is not registered in the IDE we shall display error message and it
will not be possible to create sample.
Comment 1 Tomasz Slota 2006-06-28 15:02:07 UTC
The functionality can be first exposed as a friend API to 'j2ee/samples' and
'j2ee/blueprints' but very likely it should be made a public one day as we want
to apply it for every sample that is using database, not necessarily within the
'j2ee' cluster. It could be useful for plugin developers too.
Comment 2 Andrei Badea 2006-06-29 18:22:58 UTC
Working on it. Have most of it implemented already (but see desc3 in issue
76543). Don't have time to commit it today, so hopefully tomorrow. Implemented
methods:

    public static boolean isDerbyRegistered();
    public static boolean databaseExists(String databaseName);
    public static int getFirstIllegalCharacter(String databaseName);
    public static DatabaseConnection createDatabase(String databaseName, String
user, String password) throws DatabaseException, IOException, IllegalStateException;
    public static DatabaseConnection createSampleDatabase() throws
DatabaseException, IOException, IllegalStateException; // needed for appserver
plugin
    public static DatabaseConnection createSampleDatabase(String databaseName)
throws DatabaseException, IOException;

I also plan a method like

    public static String getFirstFreeDatabaseName(String databaseName);

Comments?
Comment 3 Tomasz Slota 2006-06-29 18:50:08 UTC
Looks good to me. I think it is more logical to let the user choose user name
and password when creating the database. At very least he/she should aware of
the arbitrary values of these parameters ('APP'/'APP'), so I cold implement a
transitional solution where they are presented as read-only fields.
Comment 4 Andrei Badea 2006-06-30 15:36:22 UTC
Done. The API is in the org.netbeans.modules.db.derby.api.DerbyDatabases class.
 Should write some unit tests, so not closing yet.

Checking in db/derby/manifest.mf;
/cvs/db/derby/manifest.mf,v  <--  manifest.mf
new revision: 1.1.4.2.2.5; previous revision: 1.1.4.2.2.4
done
Checking in db/derby/nbproject/project.xml;
/cvs/db/derby/nbproject/project.xml,v  <--  project.xml
new revision: 1.4.2.2.2.3; previous revision: 1.4.2.2.2.2
done
Checking in db/derby/src/org/netbeans/modules/derby/CreateDatabaseAction.java;
/cvs/db/derby/src/org/netbeans/modules/derby/CreateDatabaseAction.java,v  <-- 
CreateDatabaseAction.java
new revision: 1.5.2.2.2.2; previous revision: 1.5.2.2.2.1
done
Checking in db/derby/src/org/netbeans/modules/derby/DerbyOptions.java;
/cvs/db/derby/src/org/netbeans/modules/derby/DerbyOptions.java,v  <-- 
DerbyOptions.java
new revision: 1.5.2.2.2.6; previous revision: 1.5.2.2.2.5
done
Checking in db/derby/src/org/netbeans/modules/derby/RegisterDerby.java;
/cvs/db/derby/src/org/netbeans/modules/derby/RegisterDerby.java,v  <-- 
RegisterDerby.java
new revision: 1.8.2.4.2.3; previous revision: 1.8.2.4.2.2
done
Checking in db/derby/src/org/netbeans/modules/derby/StartAction.java;
/cvs/db/derby/src/org/netbeans/modules/derby/StartAction.java,v  <-- 
StartAction.java
new revision: 1.2.2.1.2.2; previous revision: 1.2.2.1.2.1
done
RCS file: /cvs/db/derby/src/org/netbeans/modules/derby/Attic/Util.java,v
done
Checking in db/derby/src/org/netbeans/modules/derby/Util.java;
/cvs/db/derby/src/org/netbeans/modules/derby/Attic/Util.java,v  <--  Util.java
new revision: 1.1.2.1; previous revision: 1.1
done
RCS file:
/cvs/db/derby/src/org/netbeans/modules/derby/api/Attic/DerbyDatabases.java,v
done
Checking in db/derby/src/org/netbeans/modules/derby/api/DerbyDatabases.java;
/cvs/db/derby/src/org/netbeans/modules/derby/api/Attic/DerbyDatabases.java,v 
<--  DerbyDatabases.java
new revision: 1.1.2.1; previous revision: 1.1
done
Checking in db/derby/src/org/netbeans/modules/derby/spi/support/DerbySupport.java;
/cvs/db/derby/src/org/netbeans/modules/derby/spi/support/DerbySupport.java,v 
<--  DerbySupport.java
new revision: 1.5.2.2.2.8; previous revision: 1.5.2.2.2.7
done
Checking in db/derby/src/org/netbeans/modules/derby/ui/Bundle.properties;
/cvs/db/derby/src/org/netbeans/modules/derby/ui/Bundle.properties,v  <-- 
Bundle.properties
new revision: 1.5.2.2.2.5; previous revision: 1.5.2.2.2.4
done
Checking in db/derby/src/org/netbeans/modules/derby/ui/CreateDatabasePanel.java;
/cvs/db/derby/src/org/netbeans/modules/derby/ui/CreateDatabasePanel.java,v  <--
 CreateDatabasePanel.java
new revision: 1.4.2.2.2.2; previous revision: 1.4.2.2.2.1
done
Checking in db/external/derbysampledb.zip;
/cvs/db/external/derbysampledb.zip,v  <--  derbysampledb.zip
new revision: 1.3.8.1.2.1; previous revision: 1.3.8.1
done
Checking in serverplugins/sun/appsrv81/nbproject/project.xml;
/cvs/serverplugins/sun/appsrv81/nbproject/project.xml,v  <--  project.xml
new revision: 1.7.4.6.2.5; previous revision: 1.7.4.6.2.4
done
Checking in
serverplugins/sun/appsrv81/src/org/netbeans/modules/j2ee/sun/ide/j2ee/db/RegisterPointbase.java;
/cvs/serverplugins/sun/appsrv81/src/org/netbeans/modules/j2ee/sun/ide/j2ee/db/RegisterPointbase.java,v
 <--  RegisterPointbase.java
new revision: 1.4.6.5.2.9; previous revision: 1.4.6.5.2.8
done
Checking in ide/golden/friend-packages.txt;
/cvs/ide/golden/friend-packages.txt,v  <--  friend-packages.txt
new revision: 1.15.4.1.2.104; previous revision: 1.15.4.1.2.103
done
Comment 5 Jiri Rechtacek 2009-10-16 14:06:21 UTC
Reassigned to new owner.