本文整理汇总了Java中com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.create方法的典型用法代码示例。如果您正苦于以下问题:Java ODatabaseDocumentTx.create方法的具体用法?Java ODatabaseDocumentTx.create怎么用?Java ODatabaseDocumentTx.create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx
的用法示例。
在下文中一共展示了ODatabaseDocumentTx.create方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testJdbc
import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx; //导入方法依赖的package包/类
@Ignore
@Test
public void testJdbc() throws Exception
{
//load Driver
forName(OrientJdbcDriver.class.getName());
String dbUrl = "memory:testdb";
ODatabaseDocumentTx db = new ODatabaseDocumentTx(dbUrl);
createSchemaDB(db);
loadDB(db, 20);
db.create();
Properties info = new Properties();
info.put("user", "admin");
info.put("password", "admin");
orientJdbcConnection = (OrientJdbcConnection) DriverManager.getConnection("jdbc:orient:" + dbUrl, info);
//create and execute statement
Statement stmt = orientJdbcConnection.createStatement();
int updated = stmt.executeUpdate("INSERT into emplyoee (key, text) values('001', 'satish')");
if (orientJdbcConnection != null && !orientJdbcConnection.isClosed())
{
orientJdbcConnection.close();
}
}
示例2: doPreSetup
import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx; //导入方法依赖的package包/类
@Override
protected void doPreSetup() throws Exception {
server = OServerMain.create();
server.startup(getClass().getResourceAsStream("db.config.xml"));
server.activate();
ODatabaseDocumentTx db = new ODatabaseDocumentTx(DB_URL,false);
db = db.create();
db.command(new OCommandSQL("CREATE CLASS "+TEST_CLASS)).execute();
db.command(new OCommandSQL("CREATE PROPERTY "+TEST_CLASS+"."+TEST_PROPERTY+" STRING")).execute();
db.command(new OCommandSQL("CREATE PROPERTY "+TEST_CLASS+"."+TEST_LINK_PROPERTY+" LINK")).execute();
db.command(new OCommandSQL("CREATE CLASS "+TEST_LINKED_CLASS)).execute();
db.command(new OCommandSQL("CREATE PROPERTY "+TEST_LINKED_CLASS+"."+TEST_PROPERTY+" STRING")).execute();
db.close();
Thread.sleep(1000);
super.doPreSetup();
}
示例3: boundingBoxTestNew
import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx; //导入方法依赖的package包/类
@Test
public void boundingBoxTestNew() {
ODatabaseDocumentTx db = new ODatabaseDocumentTx("memory:test");
db.create();
try {
// Shape parse = JtsSpatialContext.GEO
// .getWktShapeParser()
// .parse(
// "POLYGON((-83.757293 42.281164, -83.749274 42.281164, -83.749274 42.275227, -83.757293 42.275227, -83.757293 42.281164))");
Shape parse = JtsSpatialContext.GEO
.makeRectangle(-83.7662120858887,-83.71986351411135, 42.26531323615103, 42.29239784478525);
Point point = JtsSpatialContext.GEO.makePoint(-83.7605452, 42.2814837);
point.relate(parse);
} catch (Exception e) {
e.printStackTrace();
} finally {
db.drop();
}
}
示例4: ContentStore
import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx; //导入方法依赖的package包/类
public ContentStore(final String type, String name) {
startupIfEnginesAreMissing();
db = new ODatabaseDocumentTx(type + ":" + name);
boolean exists = db.exists();
if (!exists) {
db.create();
}
db = ODatabaseDocumentPool.global().acquire(type + ":" + name, "admin", "admin");
ODatabaseRecordThreadLocal.INSTANCE.set(db);
if (!exists) {
updateSchema();
}
}
示例5: initDatabaseDocumentTx
import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx; //导入方法依赖的package包/类
private void initDatabaseDocumentTx(String database)
{
ODatabaseDocumentTx documentTx = new ODatabaseDocumentTx(dbUrl + database);
if (!documentTx.exists())
{
documentTx.create();
}
}
示例6: getDatabase
import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx; //导入方法依赖的package包/类
private ODatabaseDocumentTx getDatabase(String url, String userName, String password)
{
ODatabaseDocumentTx tx = new ODatabaseDocumentTx(url);
if (!tx.exists())
{
tx.create();
return tx;
}
return tx.open(userName, password);
}
示例7: init
import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx; //导入方法依赖的package包/类
private static void init(String database)
{
ODatabaseDocumentTx documentTx = new ODatabaseDocumentTx(path + database);
if (!documentTx.exists())
{
documentTx.create();
//database.open(OrientBaseGraph.ADMIN, OrientBaseGraph.ADMIN);
}
// else
// {
// database.create();
// }
}
示例8: connect
import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx; //导入方法依赖的package包/类
@Override
public ODatabaseDocumentTx connect(final String name, final boolean create) {
checkNotNull(name);
ensureStarted();
String uri = connectionUri(name);
ODatabaseDocumentTx db = new ODatabaseDocumentTx(uri);
if (db.exists()) {
db.open(SYSTEM_USER, SYSTEM_PASSWORD);
log.debug("Opened database: {} -> {}", name, db);
}
else {
if (create) {
db.create();
log.debug("Created database: {} -> {}", name, db);
// invoke created callback
try {
created(db, name);
}
catch (Exception e) {
Throwables.throwIfUnchecked(e);
throw new RuntimeException(e);
}
}
else {
log.debug("Database does not exist: {}", name);
}
}
return db;
}
示例9: createEventLogRepository
import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx; //导入方法依赖的package包/类
@Override
public boolean createEventLogRepository() {
final ODatabaseDocumentTx db = new ODatabaseDocumentTx(eventLogRepoDBUrl);
if (!db.exists()) {
db.create();
log.logp(INFO, getClass().getName(), "createEventLogRepository", String.format("created db = %s", eventLogRepoDBUrl));
return true;
} else {
return false;
}
}
示例10: getDatabase
import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx; //导入方法依赖的package包/类
/**
* @param create
* if true automatically creates database if database with given
* URL does not exist
* @param open
* if true automatically opens the database
*/
protected ODatabaseDocumentTx getDatabase(boolean create, boolean open) {
final ODatabaseDocumentTx db = new ODatabaseDocumentTx(url);
if (!db.getURL().startsWith("remote:") && !db.exists()) {
if (create)
db.create();
else if (open) throw new ODatabaseException("Database '" + url + "' not found");
} else if (open) db.open(user, password);
return db;
}
示例11: testPointTransactionRollBack
import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx; //导入方法依赖的package包/类
@Test
public void testPointTransactionRollBack() {
ODatabaseDocumentTx db = new ODatabaseDocumentTx("memory:txPoint");
try {
db.create();
OSchema schema = db.getMetadata().getSchema();
OClass v = schema.getClass("V");
OClass oClass = schema.createClass("City");
oClass.setSuperClass(v);
oClass.createProperty("location", OType.EMBEDDED, schema.getClass("OPoint"));
oClass.createProperty("name", OType.STRING);
db.command(new OCommandSQL("CREATE INDEX City.location ON City(location) SPATIAL ENGINE LUCENE")).execute();
OIndex idx = db.getMetadata().getIndexManager().getIndex("City.location");
ODocument rome = newCity("Rome", 12.5, 41.9);
ODocument london = newCity("London", -0.1275, 51.507222);
db.begin();
db.command(new OCommandSQL("insert into City set name = 'Test' , location = ST_GeomFromText('" + PWKT + "')")).execute();
db.save(rome);
db.save(london);
String query = "select * from City where location && 'LINESTRING(-160.06393432617188 21.996535232496047,-160.1099395751953 21.94304553343818,-160.169677734375 21.89399562866819,-160.21087646484375 21.844928843026818,-160.21018981933594 21.787556698550834)' ";
List<ODocument> docs = db.query(new OSQLSynchQuery<ODocument>(query));
Assert.assertEquals(1, docs.size());
Assert.assertEquals(3, idx.getSize());
db.rollback();
query = "select * from City where location && 'LINESTRING(-160.06393432617188 21.996535232496047,-160.1099395751953 21.94304553343818,-160.169677734375 21.89399562866819,-160.21087646484375 21.844928843026818,-160.21018981933594 21.787556698550834)' ";
docs = db.query(new OSQLSynchQuery<ODocument>(query));
Assert.assertEquals(0, docs.size());
Assert.assertEquals(0, idx.getSize());
} finally {
db.drop();
}
}
示例12: getGraph
import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx; //导入方法依赖的package包/类
@Override
public ODatabaseDocumentTx getGraph() {
ODatabaseDocumentTx db = getGraphNoCreate();
if (!exists(db)) {
db.create();
// Enable lightweight edges by default
db.command(new OCommandSQL("ALTER DATABASE CUSTOM useLightweightEdges = true")).execute();
}
return db;
}
示例13: testPointTransactionUpdate
import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx; //导入方法依赖的package包/类
@Test
public void testPointTransactionUpdate() {
ODatabaseDocumentTx db = new ODatabaseDocumentTx("memory:txPoint");
try {
db.create();
OSchema schema = db.getMetadata().getSchema();
OClass v = schema.getClass("V");
OClass oClass = schema.createClass("City");
oClass.setSuperClass(v);
oClass.createProperty("location", OType.EMBEDDED, schema.getClass("OPoint"));
oClass.createProperty("name", OType.STRING);
db.command(new OCommandSQL("CREATE INDEX City.location ON City(location) SPATIAL ENGINE LUCENE")).execute();
OIndex idx = db.getMetadata().getIndexManager().getIndex("City.location");
ODocument rome = newCity("Rome", 12.5, 41.9);
db.begin();
db.save(rome);
db.commit();
String query = "select * from City where location && 'LINESTRING(-160.06393432617188 21.996535232496047,-160.1099395751953 21.94304553343818,-160.169677734375 21.89399562866819,-160.21087646484375 21.844928843026818,-160.21018981933594 21.787556698550834)' ";
List<ODocument> docs = db.query(new OSQLSynchQuery<ODocument>(query));
Assert.assertEquals(0, docs.size());
Assert.assertEquals(1, idx.getSize());
db.begin();
db.command(new OCommandSQL("update City set location = ST_GeomFromText('" + PWKT + "')")).execute();
query = "select * from City where location && 'LINESTRING(-160.06393432617188 21.996535232496047,-160.1099395751953 21.94304553343818,-160.169677734375 21.89399562866819,-160.21087646484375 21.844928843026818,-160.21018981933594 21.787556698550834)' ";
docs = db.query(new OSQLSynchQuery<ODocument>(query));
Assert.assertEquals(1, docs.size());
Assert.assertEquals(1, idx.getSize());
db.commit();
query = "select * from City where location && 'LINESTRING(-160.06393432617188 21.996535232496047,-160.1099395751953 21.94304553343818,-160.169677734375 21.89399562866819,-160.21087646484375 21.844928843026818,-160.21018981933594 21.787556698550834)' ";
docs = db.query(new OSQLSynchQuery<ODocument>(query));
Assert.assertEquals(1, docs.size());
Assert.assertEquals(1, idx.getSize());
} finally {
db.drop();
}
}
示例14: boundingBoxTest
import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx; //导入方法依赖的package包/类
@Test
public void boundingBoxTest() {
ODatabaseDocumentTx db = new ODatabaseDocumentTx("memory:test");
db.create();
try {
OClass point = db.getMetadata().getSchema().createClass("Point");
point.createProperty("latitude", OType.DOUBLE);
point.createProperty("longitude", OType.DOUBLE);
db.command(new OCommandSQL("CREATE INDEX Point.ll ON Point(latitude,longitude) SPATIAL ENGINE LUCENE")).execute();
ODocument document = new ODocument("Point");
document.field("latitude", 42.2814837);
document.field("longitude", -83.7605452);
db.save(document);
List<?> query = db
.query(new OSQLSynchQuery<ODocument>(
"SELECT FROM Point WHERE [latitude, longitude] WITHIN [[42.26531323615103,-83.71986351411135],[42.29239784478525,-83.7662120858887]]"));
Assert.assertEquals(query.size(), 1);
} finally {
db.drop();
}
}