String dbname = InternalDriver.getDatabaseName(url, info);
// convert the ;name=value attributes in the URL into
// properties.
FormatableProperties finfo = getAttributes(url, info);
info = null; // ensure we don't use this reference directly again.
boolean encryptDB = Boolean.valueOf(finfo.getProperty(Attribute.DATA_ENCRYPTION)).booleanValue();
String encryptpassword = finfo.getProperty(Attribute.BOOT_PASSWORD);
if (dbname.length() == 0 || (encryptDB = true && encryptpassword == null)) {
// with no database name we can have shutdown or a database name
// In future, if any new attribute info needs to be included in this
// method, it just has to be added to either string or boolean or secret array
// depending on whether it accepts string or boolean or secret(ie passwords) value.
String[][] connStringAttributes = {
{Attribute.DBNAME_ATTR, MessageId.CONN_DATABASE_IDENTITY},
{Attribute.CRYPTO_PROVIDER, MessageId.CONN_CRYPTO_PROVIDER},
{Attribute.CRYPTO_ALGORITHM, MessageId.CONN_CRYPTO_ALGORITHM},
{Attribute.CRYPTO_KEY_LENGTH, MessageId.CONN_CRYPTO_KEY_LENGTH},
{Attribute.CRYPTO_EXTERNAL_KEY, MessageId.CONN_CRYPTO_EXTERNAL_KEY},
{Attribute.TERRITORY, MessageId.CONN_LOCALE},
{Attribute.COLLATION, MessageId.CONN_COLLATION},
{Attribute.USERNAME_ATTR, MessageId.CONN_USERNAME_ATTR},
{Attribute.LOG_DEVICE, MessageId.CONN_LOG_DEVICE},
{Attribute.ROLL_FORWARD_RECOVERY_FROM, MessageId.CONN_ROLL_FORWARD_RECOVERY_FROM},
{Attribute.CREATE_FROM, MessageId.CONN_CREATE_FROM},
{Attribute.RESTORE_FROM, MessageId.CONN_RESTORE_FROM},
};
String[][] connBooleanAttributes = {
{Attribute.SHUTDOWN_ATTR, MessageId.CONN_SHUT_DOWN_CLOUDSCAPE},
{Attribute.DEREGISTER_ATTR, MessageId.CONN_DEREGISTER_AUTOLOADEDDRIVER},
{Attribute.CREATE_ATTR, MessageId.CONN_CREATE_DATABASE},
{Attribute.DATA_ENCRYPTION, MessageId.CONN_DATA_ENCRYPTION},
{Attribute.UPGRADE_ATTR, MessageId.CONN_UPGRADE_DATABASE},
};
String[][] connStringSecretAttributes = {
{Attribute.BOOT_PASSWORD, MessageId.CONN_BOOT_PASSWORD},
{Attribute.PASSWORD_ATTR, MessageId.CONN_PASSWORD_ATTR},
};
DriverPropertyInfo[] optionsNoDB = new DriverPropertyInfo[connStringAttributes.length+
connBooleanAttributes.length+
connStringSecretAttributes.length];
int attrIndex = 0;
for( int i = 0; i < connStringAttributes.length; i++, attrIndex++ )
{
optionsNoDB[attrIndex] = new DriverPropertyInfo(connStringAttributes[i][0],
finfo.getProperty(connStringAttributes[i][0]));
optionsNoDB[attrIndex].description = MessageService.getTextMessage(connStringAttributes[i][1]);
}
optionsNoDB[0].choices = Monitor.getMonitor().getServiceList(Property.DATABASE_MODULE);
// since database name is not stored in FormatableProperties, we
// assign here explicitly
optionsNoDB[0].value = dbname;
for( int i = 0; i < connStringSecretAttributes.length; i++, attrIndex++ )
{
optionsNoDB[attrIndex] = new DriverPropertyInfo(connStringSecretAttributes[i][0],
(finfo.getProperty(connStringSecretAttributes[i][0]) == null? "" : "****"));
optionsNoDB[attrIndex].description = MessageService.getTextMessage(connStringSecretAttributes[i][1]);
}
for( int i = 0; i < connBooleanAttributes.length; i++, attrIndex++ )
{
optionsNoDB[attrIndex] = new DriverPropertyInfo(connBooleanAttributes[i][0],
Boolean.valueOf(finfo == null? "" : finfo.getProperty(connBooleanAttributes[i][0])).toString());
optionsNoDB[attrIndex].description = MessageService.getTextMessage(connBooleanAttributes[i][1]);
optionsNoDB[attrIndex].choices = BOOLEAN_CHOICES;
}
return optionsNoDB;