create=true attribute

The create=true attribute creates the standard database specified within the database connection URL Derby system and then connects to it.

If the database cannot be created, the error appears in the error log and the connection attempt fails with an SQLException indicating that the database cannot be found.

If the database already exists, the attribute creates a connection to the existing database, and an SQLWarning is issued.

JDBC does not remove the database on failure to connect at create time if failure occurs after the database call occurs. If a database connection URL used create=true and the connection fails to be created, check for the database directory. If it exists, remove it and its contents before the next attempt to create the database.

Database owner

When the database is created, the current authorization identifier becomes the database owner (see the user=userName attribute). If authentication and SQL authorization are both enabled (see "Configuring user authentication" and "Configuring user authorization" in the Derby Security Guide), only the database owner can shut down or drop the database, encrypt it, reencrypt it with a new boot password or new encryption key, or perform a full upgrade. If authentication is not enabled, and no user is supplied, the database owner defaults to "APP", which is also the name of the default schema (see SET SCHEMA statement).

Combining with other attributes

You must specify a databaseName (after the subprotocol or subsubprotocol in the database connection URL) or a databaseName=nameofDatabase attribute with this attribute.

You can combine this attribute with other attributes. To specify a locale when creating a database, use the territory=ll_CC attribute.


Creating a file system database:

-- create a file system database
-- create a file system database using the databaseName attribute
-- create an in-memory database using the embedded driver
-- create an in-memory database using the databaseName attribute
-- create an in-memory database using the Network Server

See "Using in-memory databases" in the Derby Developer's Guide for information on creating in-memory databases.