}
private boolean createDatabase() {
// Ask for the admin password
try {
PVDatabase db = new PVDatabase();
db.setName( nameFld.getText() );
PhotovaultSettings settings = PhotovaultSettings.getSettings();
settings.addDatabase( db );
String user = "";
String passwd = "";
if ( dbServerBtn.isSelected() ) {
AdminLoginDlg loginDlg = new AdminLoginDlg( this, true );
if ( loginDlg.showDialog() == AdminLoginDlg.LOGIN_DLG_OK ) {
user = loginDlg.getUsername();
passwd = loginDlg.getPasswd();
}
db.setDbName( dbNameFld.getText() );
db.setHost( dbHostFld.getText() );
Volume vol = new Volume( "defaultVolume", volumeDirFld.getText() );
try {
db.addVolume( vol );
} catch (PhotovaultException ex) {
// Should not happen...
}
} else {
// Creating an embedded database
db.setInstanceType( PVDatabase.TYPE_EMBEDDED );
db.setEmbeddedDirectory( new File( volumeDirFld.getText() ) );
}
db.createDatabase( user, passwd );
settings.saveConfig();
} catch (PhotovaultException ex) {
JOptionPane.showMessageDialog( this, ex.getMessage(),
"Error creating database", JOptionPane.ERROR_MESSAGE );
return false;