}
}
}
private void readSettingsFromURL() {
DbSettings dbSettings = DbSettings.getInstance();
//Lealone的JDBC URL语法:
//jdbc:lealone:tcp://[host:port],[host:port].../[database][;propertyName1][=propertyValue1][;propertyName2][=propertyValue2]
//数据库名与参数之间用';'号分隔,不同参数之间也用';'号分隔
int idx = url.indexOf(';');
char splitChar = ';';
if (idx < 0) {
//看看是否是MySQL的JDBC URL语法:
//jdbc:mysql://[host:port],[host:port].../[database][?propertyName1][=propertyValue1][&propertyName2][=propertyValue2]
//数据库名与参数之间用'?'号分隔,不同参数之间用'&'分隔
idx = url.indexOf('?');
if (idx >= 0)
splitChar = '&';
}
if (idx >= 0) {
String settings = url.substring(idx + 1);
url = url.substring(0, idx); //去掉后面的参数
String[] list = StringUtils.arraySplit(settings, splitChar, false);
for (String setting : list) {
if (setting.length() == 0) {
continue;
}
int equal = setting.indexOf('=');
if (equal < 0) {
throw getFormatException();
}
String value = setting.substring(equal + 1);
String key = setting.substring(0, equal);
key = StringUtils.toUpperEnglish(key);
if (!isKnownSetting(key) && !dbSettings.containsKey(key)) {
throw DbException.get(ErrorCode.UNSUPPORTED_SETTING_1, key);
}
String old = prop.getProperty(key);
if (old != null && !old.equals(value)) {
throw DbException.get(ErrorCode.DUPLICATE_PROPERTY_1, key);