I'm tring to use orientdb. The sample is very simple:
package models;
import java.util.List;
import com.orientechnologies.orient.core.db.object.ODatabaseObjectPool;
import com.orientechnologies.orient.core.db.object.ODatabaseObjectTx;
import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery;
public class User {
public String name;
public static void main(String[] args) {
String uri = "local:c:\\orientdb";
ODatabaseObjectTx db = ODatabaseObjectPool.global().acquire(uri, "admin", "admin");
db.getEntityManager().registerEntityClass(User.class);
User user = new User();
user.name = "aaa";
db.save(user);
List<?> list = db.query(new OSQLSynchQuery<Long>("select count(*) from User"));
System.out.println(list);
db.commit();
db.close(); // ****** throws exception
}
}
But the last line db.close()
will throw an exception:
Exception in thread "main" com.orientechnologies.common.concur.lock.OLockException: Can't release a database URL not acquired before. URL: c:\orientdb
at com.orientechnologies.orient.core.db.ODatabasePoolAbstract.release(ODatabasePoolAbstract.java:81)
at com.orientechnologies.orient.core.db.ODatabasePoolBase.release(ODatabasePoolBase.java:43)
at com.orientechnologies.orient.core.db.object.ODatabaseObjectTxPooled.close(ODatabaseObjectTxPooled.java:81)
at models.User.main(User.java:26)
Where is wrong?
Finally, I found it a bug of Orientdb. It can't handle windows path correctly, and not provide good error messages.
If I use local:c:/orientdb
not local:c:\orientdb
, everything is fine.
I have reported this to orientdb team.