Creating an embedded Database with Java

148 views
Skip to first unread message

Martin Sandig

unread,
Jul 3, 2015, 3:54:58 AM7/3/15
to orient-...@googlegroups.com
Hallo Community,

I´ve got an problem....

I want to create a new database with classes and properties on an embedded orientdb-server.
If the server starts I can connect to it and create the orientdb graph database, but I can´t execute sql-commands to create classe and so on .....

Do any of you have any idea how to do that?

Thank you for your answers :)

Luigi Dell'Aquila

unread,
Jul 3, 2015, 3:57:46 AM7/3/15
to orient-...@googlegroups.com
Hi Martin,

how are you starting the embedded server? Are you following this? http://orientdb.com/docs/last/Embedded-Server.html

Could you please share some additional info about how you are doing schema operations? Are you using Studio or are you executing commands from the Java application? Which OrientDB version?

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

Martin Sandig

unread,
Jul 3, 2015, 4:16:55 AM7/3/15
to orient-...@googlegroups.com
Sorry Luigi, I forgot the infomation :D

I work with maven 3.2.3 and in the pom.xml are the following dependenies:

<dependency>
   
<groupId>com.orientechnologies</groupId>
   
<artifactId>orientdb-graphdb</artifactId>
</dependency>
<dependency>
   
<groupId>com.orientechnologies</groupId>
   
<artifactId>orientdb-client</artifactId>
 
</dependency>

I think it version 2.0.10.

My code:

server = OServerMain.create();
        server
.startup(EmbeddedServer.class.getClassLoader()
               
.getResourceAsStream(configFile));
        server
.activate();
       
OrientGraphFactory factory = new OrientGraphFactory(uri+"/"+databaseName, user, password);
       
OrientGraph graph = factory.getTx();
       graph
.command(new OCommandSQL(sqlCommmand)).execute());

        graph
.commit();
        graph
.shutdown();
        factory
.close();


When I run the SQL commands, the following exception occurs.

com.orientechnologies.orient.core.sql.OCommandSQLParsingException: Error on parsing command at position #27: Super-class E; not exists



My orientdb-config.xml

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<orient-server>
   
<handlers>
       
<handler
           
class="com.orientechnologies.orient.graph.handler.OGraphServerHandler">
           
<parameters>
               
<parameter value="true" name="enabled" />
               
<parameter value="50" name="graph.pool.max" />
           
</parameters>
       
</handler>
   
</handlers>
   
<network>
       
<protocols>
           
<protocol
               
implementation="com.orientechnologies.orient.server.network.protocol.binary.ONetworkProtocolBinary"
               
name="binary" />
           
<protocol
               
implementation="com.orientechnologies.orient.server.network.protocol.http.ONetworkProtocolHttpDb"
               
name="http" />
       
</protocols>
       
<listeners>
           
<listener protocol="binary" socket="default" port-range="12424-12430"
               
ip-address="0.0.0.0" />
           
<listener protocol="http" socket="default" port-range="12480-12490"
               
ip-address="0.0.0.0">
               
<commands>
                   
<command
                       
implementation="com.orientechnologies.orient.server.network.protocol.http.command.get.OServerCommandGetStaticContent"
                       
pattern="GET|www GET|studio/ GET| GET|*.htm GET|*.html GET|*.xml GET|*.jpeg GET|*.jpg GET|*.png GET|*.gif GET|*.js GET|*.css GET|*.swf GET|*.ico GET|*.txt GET|*.otf GET|*.pjs GET|*.svg GET|*.json GET|*.woff GET|*.ttf GET|*.svgz"
                       
stateful="false">
                       
<parameters>
                           
<entry
                               
value="Cache-Control: no-cache, no-store, max-age=0, must-revalidate\r\nPragma: no-cache"
                               
name="http.cache:*.htm *.html" />
                           
<entry value="Cache-Control: max-age=120" name="http.cache:default" />
                       
</parameters>
                   
</command>
                   
<command
                       
implementation="com.orientechnologies.orient.graph.server.command.OServerCommandGetGephi"
                       
pattern="GET|gephi/*" stateful="false" />
               
</commands>
               
<parameters>
                   
<parameter value="utf-8" name="network.http.charset" />
               
</parameters>
           
</listener>
       
</listeners>
   
</network>
   
<storages>
       
<storage name="test" path="plocal:...../databases/test"
         
userName="root" userPassword="....."
         
loaded-at-startup="true" />
   
</storages>
   
<users>
       
<user resources="*" password="root" name="root" />
       
<user resources="connect,server.listDatabases,server.dblist"
           
password="guest" name="guest" />
   
</users>
   
<properties>
       
<entry
           
value="....databases"
           
name="server.database.path" />
       
<entry value="1" name="db.pool.min" />
       
<entry value="50" name="db.pool.max" />
       
<entry value="true" name="profiler.enabled" />
       
<entry value="info" name="log.console.level" />
       
<entry value="fine" name="log.file.level" />
   
</properties>
</orient-server>



Luca Garulli

unread,
Jul 4, 2015, 4:34:43 AM7/4/15
to orient-...@googlegroups.com
Hi,
The problem is in the command: remove the ; at the end of the sql command.

Best Regards,

Luca Garulli
CEO at Orient Technologies LTD
the Company behind OrientDB

On 3 July 2015 at 10:16, Martin Sandig <martins...@gmail.com> wrote:
Sorry Luigi, I forgot the infomation :D

I work with maven 3.2.3 and in the pom.xml are the following dependenies:

<dependency>
   
<groupId>com.orientechnologies</groupId>
   
<artifactId>orientdb-graphdb</artifactId>
</dependency>
<dependency>
   
<groupId>com.orientechnologies</groupId>
   
<artifactId>orientdb-client</artifactId>
 
</dependency>

I think it version 2.0.10.

My code:

server = OServerMain.create();
        server
.startup(EmbeddedServer.class.getClassLoader()
               
.getResourceAsStream(configFile));
        server
.activate();
       
OrientGraphFactory factory = new OrientGraphFactory(uri+"/"+databaseName, user, password);
       
OrientGraph graph = factory.getTx();
       graph
.command(new OCommandSQL(sqlCommmand)).execute());

               
           
} catch (IOException ex) {
                ex
.printStackTrace();
           
}
       
        graph
.commit();
        graph
.shutdown();
        factory
.close();

Jay Moss

unread,
Aug 3, 2015, 2:20:15 PM8/3/15
to OrientDB, l.ga...@orientdb.com
So what class is EmbeddedServer and where is it's dependency? 

It's not resolving in my code with any orient db dependencies (tried the two listed plus commons/core/enterprise/object).

It would really be nice to have a good working and complete example of an orientdb embedded client.
Reply all
Reply to author
Forward
0 new messages