提交 df754bec authored 作者: Thomas Mueller's avatar Thomas Mueller

Database URLs can now be re-mapped to another URL using the system property…

Database URLs can now be re-mapped to another URL using the system property "h2.urlMap", which points to a properties file with database URL mappings.
上级 3065d6bd
......@@ -11,11 +11,13 @@ import java.sql.DriverManager;
import java.sql.DriverPropertyInfo;
import java.sql.SQLException;
import java.util.Properties;
import org.h2.constant.SysProperties;
import org.h2.engine.Constants;
import org.h2.jdbc.JdbcConnection;
import org.h2.message.DbException;
import org.h2.message.TraceSystem;
import org.h2.upgrade.DbUpgrade;
import org.h2.util.SortedProperties;
/*## Java 1.7 begin ##
import java.util.logging.Logger;
......@@ -62,6 +64,17 @@ public class Driver implements java.sql.Driver {
if (!acceptsURL(url)) {
return null;
}
String urlMap = SysProperties.URL_MAP;
if (urlMap != null && urlMap.length() > 0) {
SortedProperties prop = SortedProperties.loadProperties(urlMap);
String url2 = prop.getProperty(url);
if (url2 == null) {
prop.put(url, "");
prop.store(urlMap);
} else {
url = url2;
}
}
if (url.equals(DEFAULT_URL)) {
return DEFAULT_CONNECTION.get();
}
......
......@@ -373,6 +373,14 @@ public class SysProperties {
*/
public static final boolean TRACE_IO = Utils.getProperty("h2.traceIO", false);
/**
* System property <code>h2.urlMap</code> (default: null).<br />
* A properties file that contains a mapping between database URLs. New
* connections are written into the file. An empty value in the map means no
* redirection is used for the given URL.
*/
public static final String URL_MAP = Utils.getProperty("h2.urlMap", null);
/**
* System property <code>h2.webMaxValueLength</code> (default: 100000).<br />
* The H2 Console will abbreviate (truncate) result values larger than this size.
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论