ODatabaseDocumentTx db = new ODatabaseDocumentTx("SERVER_URL").open("USER_LOGIN","USER_PASS");
List<ODocument> result = db.query( new OSQLSynchQuery<ODocument>("select * from V_User "));
...
org.codehaus.jackson.map.JsonMappingException: Database instance is not set in current thread. Assure to set it with: ODatabaseRecordThreadLocal.INSTANCE.set(db); (through reference chain: com.orientechnologies.orient.core.record.impl.ODocument["locked"])
// OPEN THE DATABASE
ODatabaseDocumentTx db = ODatabaseDocumentPool.global().acquire("remote:localhost/petshop", "admin", "admin");
try {
// YOUR CODE
...
} finally {
db.close();
}
ODatabaseDocumentPool
is deprecated. link OrientGraphFactory graphFactory = new OrientGraphFactory(url, dbUser, dbPsw); graphFactory.setupPool(1, 10);
graphFactory.getDatabase(); // ODatabaseDocumentTx
graphFactory.getTx(); // OrientGraph
graphFactory.getNoTx(); // OrientGraphNoTx
Hi ,
You may use OParttionedDatabasePool for this case , or if you have several users you may use pool factory instead .
Maybe there is an alternative but you can get ODatabaseDocumentTx also from OrientGraphFactory:
OrientGraphFactory graphFactory = new OrientGraphFactory(url, dbUser, dbPsw);graphFactory.setupPool(1, 10);
graphFactory.getDatabase(); // ODatabaseDocumentTx
graphFactory.getTx(); // OrientGraph
graphFactory.getNoTx(); // OrientGraphNoTx
Dne pátek 18. září 2015 15:25:25 UTC+2 Mihai Ocneanu napsal(a):
Hello,
I have this simple code:
ODatabaseDocumentTx db = new ODatabaseDocumentTx("SERVER_URL").open("USER_LOGIN","USER_PASS");
List<ODocument> result = db.query( new OSQLSynchQuery<ODocument>("select * from V_User "));
...
Which works as far as the query is concerned, but, I get this error:org.codehaus.jackson.map.JsonMappingException: Database instance is not set in current thread. Assure to set it with: ODatabaseRecordThreadLocal.INSTANCE.set(db); (through reference chain: com.orientechnologies.orient.core.record.impl.ODocument["locked"])
The solution - I think - is to use the pooled connection factory, but I can't figure it out.
The documentation states:
// OPEN THE DATABASE
ODatabaseDocumentTx db = ODatabaseDocumentPool.global().acquire("remote:localhost/petshop", "admin", "admin");
try {
// YOUR CODE
...
} finally {
db.close();
}
BUTODatabaseDocumentPool
is deprecated. link
How am I supposed to initialize the factory and get an instance?
Thanks,
Mihai
--
---
You received this message because you are subscribed to the Google Groups "OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to orient-databa...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
OPartitionedDatabasePoolFactory factory = new OPartitionedDatabasePoolFactory();
OPartitionedDatabasePool oPartitionedDatabasePool = factory.get(SERVER_URL, USER_LOGIN, USER_PASS);
ODatabaseDocumentTx odbTx = oPartitionedDatabasePool.acquire();
Thank you both for your answers.
Andrey, would you say this is what you mean when you mentioned OParttionedDatabasePool? Is this the proper way?
OPartitionedDatabasePoolFactory factory = new OPartitionedDatabasePoolFactory();
OPartitionedDatabasePool oPartitionedDatabasePool = factory.get(SERVER_URL, USER_LOGIN, USER_PASS);
ODatabaseDocumentTx odbTx = oPartitionedDatabasePool.acquire();
Thanks,
Mihai
--