如何使用java连接orientdb数据库?

时间:2015-05-18 07:08:47

标签: java database orientdb

我尝试使用orientdb数据库与java连接。像这样     OrientGraph odb = new OrientGraph("plocal:C:/Users/USER/Desktop/orientdb/databases/testJ", "admin", "admin");

显示错误

  

HTTP状态500 - 处理程序处理失败;嵌套异常是java.lang.NoClassDefFoundError:com / orientechnologies / orient / core / db / record / ODatabaseRecord

我的依赖..

    <dependency>
        <groupId>com.orientechnologies</groupId>
        <artifactId>orientdb-core</artifactId>
        <version>2.0.8</version>
    </dependency>
    <dependency>
      <groupId>com.orientechnologies</groupId>
      <artifactId>orientdb-jdbc</artifactId>
      <version>1.7</version>
    </dependency>
    <dependency>
      <groupId>com.tinkerpop</groupId>
      <artifactId>pipes</artifactId>
      <version>2.4.0</version>
    </dependency>
    <dependency>
       <groupId>com.tinkerpop.blueprints</groupId>
       <artifactId>blueprints-core</artifactId>
       <version>2.4.0</version>
    </dependency>
    <dependency>
        <groupId>com.tinkerpop.blueprints</groupId>
        <artifactId>blueprints-orient-graph</artifactId>
        <version>2.4.0</version>
    </dependency>

帮我解决错误.. 提前谢谢你

1 个答案:

答案 0 :(得分:1)

ODatabaseRecord似乎已从新版本弃用。我对您的代码进行了以下更改,并且工作正常(删除所有其他依赖项)。

<强> POM

<dependency>
  <groupId>com.orientechnologies</groupId>
  <artifactId>orientdb-core</artifactId>
  <version>2.0.8</version>
</dependency>
<dependency>
  <groupId>com.orientechnologies</groupId>
  <artifactId>orientdb-jdbc</artifactId>
  <version>2.0.8</version>
</dependency>

Java代码

OrientGraphFactory ogf = new OrientGraphFactory(
            "plocal:C:/Users/USER/Desktop/orientdb/databases/testJ", "admin", "admin");
    OrientGraph og = ogf.getTx();

    try {
        System.out.println("Features = " + og.getFeatures());
    } finally {
        og.shutdown();
    }

注意:我找到了线索here