apache > db
Apache DB Project
 
Font size:      

Shutting Down or Creating a Database

Shutting Down or Creating a Database

If you need to shut down or create a database, it is easiest just to work with the Derby-specific implementations of interfaces, as shown in the following examples.

javax.sql.XADataSource xads = makeXADataSource(mydb, true);
 
 
// example of setting property directory using 
// Derby 's XADataSource object
import org.apache.derby.jdbc.EmbeddedXADataSource;
import javax.sql.XADataSource;
// dbname is the database name
// if create is true, create the database if not already created
XADataSource makeXADataSource (String dbname, boolean create) 
{
    DerbyXADataSource xads = new DerbyXADataSource();
    // use Derby 's setDatabaseName call
    xads.setDatabaseName(dbname);
    if (create)
        xads.setCreateDatabase("create");
    return xads;
}

Setting the property does not create or shut down the database. The database is not actually created or shut down until the next connection request.


Previous Page
Next Page
Table of Contents
Index