OrientDB版本2.1.8 GA。不支持具有UNC路径的数据库URL:
以下是演示错误的简单程序:
public class ConnectionString
{
public static void main(String[] args)
{
String url = "plocal:\\\\srv\\db\\Database";
ODatabaseDocumentTx db = null;
try
{
db = new ODatabaseDocumentTx(url).open("admin", "admin");
System.out.println("Database is opened");
}
finally
{
if(db != null)
db.close();
}
}
}
将此代码调试到com.orientechnologies.orient.core.Orient类中的方法loadStorage(String iURL)
:
public OStorage loadStorage(String iURL) {
// iURL = "plocal://srv/db/Database" OK
if (iURL == null || iURL.length() == 0)
throw new IllegalArgumentException("URL missed");
if (iURL.endsWith("/"))
iURL = iURL.substring(0, iURL.length() - 1);
// This code comes too early. Engine prefix is not yet removed from the iURL
if (isWindowsOS()) {
// WINDOWS ONLY: REMOVE DOUBLE SLASHES NOT AS PREFIX (WINDOWS PATH COULD NEED STARTING FOR "\\". EXAMPLE: "\\mydrive\db"). AT
// THIS LEVEL BACKSLASHES ARRIVES AS SLASHES
iURL = iURL.charAt(0) + iURL.substring(1).replace("//", "/");
// After that statement iURL = "plocal:/srv/db/Database" UNC prefix is lost!
} else
// REMOVE ANY //
iURL = iURL.replace("//", "/");
// SEARCH FOR ENGINE
int pos = iURL.indexOf(':');
if (pos <= 0)
throw new OConfigurationException("Error in database URL: the engine was not specified. Syntax is: " + URL_SYNTAX
+ ". URL was: " + iURL);
稍后我们得到预期的异常:
Exception in thread "main" com.orientechnologies.orient.core.exception.OStorageException: Cannot open local storage '/srv/db/Database' with mode=rw
at com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage.open(OAbstractPaginatedStorage.java:248)
at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.open(ODatabaseDocumentTx.java:252)
at com.riag.test.dbengine.skin.orientdb.ConnectionString.main(ConnectionString.java:22)