DBA > Job Interview Questions > DERBY Java Database FAQs

How to shut down or create a Database?

More DBA job interview questions and answers at http://dba.fyicenter.com/Interview-Questions/

(Continued from previous question...)

How to shut down or create 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.

(Continued on next question...)

Other Job Interview Questions