public class Program {
static String _storageType = "memory";
static String _databaseName = "TestDB";
public static void main(String[] args) throws IOException {
OServerAdmin server = new
OServerAdmin("remote:localhost").connect("root", "root");
server.createDatabase(_databaseName, "graph", _storageType);
server.close();
ODatabaseDocumentTx database = null;
ODatabaseDocumentPool pool;
try {
pool = new ODatabaseDocumentPool("remote:localhost/" +
_databaseName, "admin", "admin");
database = pool.acquire();
ODocument doc = new ODocument("Person");
doc.field("Name", "Johny");
doc.save();
} finally {
if (database != null) {
database.close();
}
}
server = new OServerAdmin("remote:localhost").connect("root", "root");
if (server.existsDatabase(_storageType)) {
server.dropDatabase(_storageType);
}
server.close();
}
}
This works for me.
sábado, 3 de Janeiro de 2015 às 13:08:35 UTC, GoorMoon escreveu:
>
> Hello,
>
> I am trying to reproduce some error in Java and need some help (i am new
> in java)
> Write simple program to connect to the orientdb server version 1.7.10
>
> import java.io.IOException;
>
> import com.orientechnologies.orient.client.remote.OServerAdmin;
> import com.orientechnologies.orient.core.db.document.ODatabaseDocumentPool;
> import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx;
> import com.orientechnologies.orient.core.record.impl.ODocument;
>
> public class Program {
> static String _storageType = "memory";
> static String _databaseName = "TestDB";
> public static void main(String[] args) throws IOException {
> OServerAdmin server = new
> OServerAdmin("remote:localhost/"+_databaseName).connect("admin", "admin");
> if(!server.existsDatabase(_storageType))
> server.createDatabase("graph", _storageType);
> server.close();
> ODatabaseDocumentTx database=null;
> ODatabaseDocumentPool pool = null;
> try
> {
> pool = new
> ODatabaseDocumentPool("remote:localhost/"+_databaseName,"admin","admin");
> database = pool.acquire();
> ODocument doc = new ODocument("Person");
> doc.field("Name","Johny");
> doc.save();
> }
> finally
> {
> if(database != null)
> database.close();
> }
> server = new
> OServerAdmin("remote:localhost/"+_databaseName).connect("admin", "admin");
> if(server.existsDatabase(_storageType))
> server.dropDatabase(_storageType);
> server.close();
> }
> }
>
> Program stuck on the line doc.save and each few milliseconds create a new
> record.
>
> and i sea following exceptions in the log:
>
> ינו 03, 2015 3:02:27 PM com.orientechnologies.common.log.OLogManager log
> SEVERE: Removing disconnected network channel '127.0.0.1:2424/TestDB'...
> ינו 03, 2015 3:02:27 PM com.orientechnologies.common.log.OLogManager log
> SEVERE: Removing disconnected network channel '127.0.0.1:2424/TestDB'...
> ינו 03, 2015 3:02:28 PM com.orientechnologies.common.log.OLogManager log
> SEVERE: Removing disconnected network channel '127.0.0.1:2424/TestDB'...
> ינו 03, 2015 3:02:29 PM com.orientechnologies.common.log.OLogManager log
> SEVERE: Removing disconnected network channel '127.0.0.1:2424/TestDB'...
> ינו 03, 2015 3:02:46 PM com.orientechnologies.common.log.OLogManager log
> WARNING: Caught I/O errors from /127.0.0.1:2424 (local socket=/
> 127.0.0.1:50490), trying to reconnect (error:
> java.net.SocketTimeoutException: Read timed out)
> ינו 03, 2015 3:02:46 PM com.orientechnologies.common.log.OLogManager log
> SEVERE: Removing disconnected network channel '127.0.0.1:2424/TestDB'...
> ינו 03, 2015 3:02:46 PM com.orientechnologies.common.log.OLogManager log
> WARNING: Connection re-acquired transparently after 14ms and 1 retries: no
> errors will be thrown at application level
> ינו 03, 2015 3:03:01 PM com.orientechnologies.common.log.OLogManager log
> WARNING: Caught I/O errors from /127.0.0.1:2424 (local socket=/
> 127.0.0.1:50491), trying to reconnect (error:
> java.net.SocketTimeoutException: Read timed out)
> ינו 03, 2015 3:03:01 PM com.orientechnologies.common.log.OLogManager log
> SEVERE: Removing disconnected network channel '127.0.0.1:2424/TestDB'...
> ינו 03, 2015 3:03:01 PM com.orientechnologies.common.log.OLogManager log
> WARNING: Connection re-acquired transparently after 33ms and 1 retries: no
> errors will be thrown at application level
>
> What i am doing wrong ?
>
>
--
---
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 [email protected].
For more options, visit https://groups.google.com/d/optout.