In 3.0.0 unlike ODatabaseDocumentTx , OrientDB constructor throwing exception for in memory DB

43 views
Skip to first unread message

arjun dhar

unread,
May 14, 2018, 1:23:11 AM5/14/18
to OrientDB
Hi,

Summary
Am on OrientDB 3.0.0 ; and am trying to avoid the use of Depreicated API like: ODatabaseDocumentTx
However, when I replace it with com.orientechnologies.orient.core.db.OrientDB ; for the same configs that otherwise work fine it blows up.

Details below...

Configuration
```
odb.url=memory:neurosys_orientdb_odb
odb.username=admin
odb.password=admin
odb.maxPartitionSize=2
odb.maxPoolSize=10
```

Spring Configs usinODatabaseDocumentTx that work
```
<bean id="dataSourceOdb" class="com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx" init-method="create">
        <constructor-arg value = "${odb.url}"/>   
</bean>

<bean id="connectionPoolDataSourceOdb" class="com.orientechnologies.orient.core.db.OPartitionedDatabasePool">
  <constructor-arg value = "${odb.url}" index="0"/>
  <constructor-arg value = "${odb.username}" index="1"/>
  <constructor-arg value = "${odb.password}" index="2"/>
  <constructor-arg value = "${odb.maxPartitionSize}" index="3"/>
        <constructor-arg value = "${odb.maxPoolSize}" index="4"/>
  </bean>
```

Spring Configs using com.orientechnologies.orient.core.db.OrientDB that does not work
Simply replacing the  `dataSourceOdb` bean.
```
<bean id="dataSourceOdbNew" class="com.orientechnologies.orient.core.db.OrientDB">  
    <constructor-arg value = "${odb.url}"/>
  <constructor-arg value = "${odb.username}" />
  <constructor-arg value = "${odb.password}" />   
    <constructor-arg><null /></constructor-arg>
</bean>
```

Exception thrown
```
com.orientechnologies.orient.core.exception.ODatabaseException: Cannot open database 'neurosys_orientdb_odb'
at com.orientechnologies.orient.core.db.OrientDBEmbedded.open(OrientDBEmbedded.java:140)
at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.open(ODatabaseDocumentTx.java:908)
at com.orientechnologies.orient.core.db.OPartitionedDatabasePool$DatabaseDocumentTxPooled.internalOpen(OPartitionedDatabasePool.java:441)
at com.orientechnologies.orient.core.db.OPartitionedDatabasePool.openDatabase(OPartitionedDatabasePool.java:306)
at com.orientechnologies.orient.core.db.OPartitionedDatabasePool.acquire(OPartitionedDatabasePool.java:261)
...
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: com.orientechnologies.orient.core.exception.OStorageException: Cannot open the storage 'neurosys_orientdb_odb' because it does not exist in path: D:\orientdb\./neurosys_orientdb_odb
at com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage.open(OAbstractPaginatedStorage.java:267)
at com.orientechnologies.orient.core.db.OrientDBEmbedded.open(OrientDBEmbedded.java:131)
... 34 more

```

Possible cause
Looks like the path is getting messed up and assuming unix convention path even for an in memory DB. Am on windows, but I dont see why that anyway matters for an in-memory DB, plus it works with the deprecated one. So I assume this to be a bug, if not please let me know what Im missing.

thanks,
Arjun

Luigi Dell'Aquila

unread,
May 14, 2018, 3:16:42 AM5/14/18
to orient-...@googlegroups.com
Hi Arjun,

Thank you very much for reporting, I'll check it asap.

Thanks

Luigi

--

---
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-database+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Luigi Dell'Aquila

unread,
May 14, 2018, 8:07:27 AM5/14/18
to orient-...@googlegroups.com
Hi Arjun,

With the new API the db creation is a bit different, programmatically it would be something as follows:

OrientDB orient = new OrientDB("embedded:./",config);
orient.create("neurosys_orientdb_odb",ODatabaseType.MEMORY);

// and create a pool
ODatabasePool pool = new ODatabasePool(orient,"neurosys_orientdb_odb","admin","admin",config);

// or open a connection directly
orient.open("neurosys_orientdb_odb","admin","admin",config);


So you need four parameters:
- the db path ("embedded:./" in this case, but if you only have in-memory databases you can hard-wire it, as it will never be used)
- the actual db name (neurosys_orientdb_odb)
- the username
- the password

Probably you will have to do little changes to your application accordingly, but it should not be too complex

I hope it helps

Thanks

Luigi




Reply all
Reply to author
Forward
0 new messages