diff --git a/README.textile b/README.textile index e3d1f2a0971..4e6fa949347 100644 --- a/README.textile +++ b/README.textile @@ -27,12 +27,17 @@ Do a
mvn assembly:assembly
-to obtain a jar with dependency included. +to obtain a jar with dependency included under target directory. -It is very usefull to include under applications such as DBvisualizer. +Just copy orientdb-jdbc-1.0-SNAPSHOT-all.jar to your classpath. + +It is very usefull to include under applications such as DBVisualizer. *How can be used in my code?* +The driver is registerd to the Java sql DriverManager and can be used to work with all the OrientDB database types: memory, local or remote. +The driver's class is com.orientechnologies.orient.jdbc.OrientJdbcDriver. + Use your knowledge of JDBC API to work against OrientDB. First get a connection diff --git a/src/main/java/com/orientechnologies/orient/jdbc/OrientJdbcConnection.java b/src/main/java/com/orientechnologies/orient/jdbc/OrientJdbcConnection.java index d987e24e191..05cd420df61 100644 --- a/src/main/java/com/orientechnologies/orient/jdbc/OrientJdbcConnection.java +++ b/src/main/java/com/orientechnologies/orient/jdbc/OrientJdbcConnection.java @@ -37,20 +37,19 @@ import java.util.Properties; import java.util.concurrent.Executor; -import com.orientechnologies.orient.core.db.document.ODatabaseDocumentPool; -import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx; +import com.orientechnologies.orient.core.db.graph.OGraphDatabase; +import com.orientechnologies.orient.core.db.graph.OGraphDatabasePool; /** - * TODO Add authors name * - * @author Roberto Franchini() + * @author Roberto Franchini (CELI Srl - franchini@celi.it) * @author Salvatore Piccione (TXT e-solutions SpA - salvo.picci@gmail.com) */ public class OrientJdbcConnection implements Connection { private final String dbUrl; private final Properties info; - private ODatabaseDocumentTx database; + private OGraphDatabase database; private boolean readOnly = false; private boolean autoCommit; @@ -62,7 +61,7 @@ public OrientJdbcConnection(String iUrl, Properties iInfo) { String username = iInfo.getProperty("user", "admin"); String password = iInfo.getProperty("password", "admin"); - database = ODatabaseDocumentPool.global().acquire(dbUrl, username, password); + database = OGraphDatabasePool.global().acquire(dbUrl, username, password); } @@ -278,33 +277,27 @@ public String getUrl() { return dbUrl; } - public ODatabaseDocumentTx getDatabase() { - + public OGraphDatabase getDatabase() { return database; } public void abort(Executor arg0) throws SQLException { - // TODO Auto-generated method stub } public int getNetworkTimeout() throws SQLException { - // TODO Auto-generated method stub return 0; } public String getSchema() throws SQLException { - // TODO Auto-generated method stub return null; } public void setNetworkTimeout(Executor arg0, int arg1) throws SQLException { - // TODO Auto-generated method stub } public void setSchema(String arg0) throws SQLException { - // TODO Auto-generated method stub } diff --git a/src/main/java/com/orientechnologies/orient/jdbc/OrientJdbcResultSet.java b/src/main/java/com/orientechnologies/orient/jdbc/OrientJdbcResultSet.java index 6737b8c48dc..d892fc28662 100644 --- a/src/main/java/com/orientechnologies/orient/jdbc/OrientJdbcResultSet.java +++ b/src/main/java/com/orientechnologies/orient/jdbc/OrientJdbcResultSet.java @@ -139,11 +139,7 @@ public boolean absolute(int iRowNumber) throws SQLException { } cursor = iRowNumber; - // ODatabaseRecordThreadLocal.INSTANCE.set(document.getDatabase()); document = records.get(cursor); - - // fieldNames = document.fieldNames(); - return true; } diff --git a/src/main/java/com/orientechnologies/orient/jdbc/OrientJdbcStatement.java b/src/main/java/com/orientechnologies/orient/jdbc/OrientJdbcStatement.java index 14e7f55ffb4..4cc5d45313a 100644 --- a/src/main/java/com/orientechnologies/orient/jdbc/OrientJdbcStatement.java +++ b/src/main/java/com/orientechnologies/orient/jdbc/OrientJdbcStatement.java @@ -27,7 +27,7 @@ import com.orientechnologies.orient.core.command.OCommandRequest; import com.orientechnologies.orient.core.db.ODatabaseRecordThreadLocal; -import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx; +import com.orientechnologies.orient.core.db.graph.OGraphDatabase; import com.orientechnologies.orient.core.exception.OQueryParsingException; import com.orientechnologies.orient.core.record.impl.ODocument; import com.orientechnologies.orient.core.sql.OCommandSQL; @@ -42,7 +42,7 @@ public class OrientJdbcStatement implements Statement { protected final OrientJdbcConnection connection; - protected final ODatabaseDocumentTx database; + protected final OGraphDatabase database; // protected OCommandSQL query; protected OCommandRequest query; diff --git a/src/test/java/com/orientechnologies/orient/jdbc/OrientDataSourceTest.java b/src/test/java/com/orientechnologies/orient/jdbc/OrientDataSourceTest.java index 4c1125e4fae..e1b8ea1bfa9 100644 --- a/src/test/java/com/orientechnologies/orient/jdbc/OrientDataSourceTest.java +++ b/src/test/java/com/orientechnologies/orient/jdbc/OrientDataSourceTest.java @@ -5,40 +5,25 @@ import org.junit.Test; -import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx; - import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -public class OrientDataSourceTest { - - @Test - public void shouldConnect() throws SQLException { - String dbUrl = "memory:test"; - - String username = "admin"; - String password = "admin"; - - ODatabaseDocumentTx db = new ODatabaseDocumentTx(dbUrl); - if (db.exists()) { - db.open(username, password); - db.drop(); - db.close(); - } +public class OrientDataSourceTest extends OrientJdbcBaseTest { - db.create(); + @Test + public void shouldConnect() throws SQLException { - OrientDataSource ds = new OrientDataSource(); - ds.setUrl("jdbc:orient:memory:test"); - ds.setUsername(username); - ds.setPassword(password); + OrientDataSource ds = new OrientDataSource(); + ds.setUrl("jdbc:orient:memory:test"); + ds.setUsername("admin"); + ds.setPassword("admin"); - Connection conn = ds.getConnection(); + Connection conn = ds.getConnection(); - assertNotNull(conn); - conn.close(); - assertTrue(conn.isClosed()); + assertNotNull(conn); + conn.close(); + assertTrue(conn.isClosed()); - } + } } diff --git a/src/test/java/com/orientechnologies/orient/jdbc/OrientDbCreationHelper.java b/src/test/java/com/orientechnologies/orient/jdbc/OrientDbCreationHelper.java index d49a702369b..c25ceca9c02 100644 --- a/src/test/java/com/orientechnologies/orient/jdbc/OrientDbCreationHelper.java +++ b/src/test/java/com/orientechnologies/orient/jdbc/OrientDbCreationHelper.java @@ -14,94 +14,95 @@ public class OrientDbCreationHelper { - public static void loadDB(ODatabaseDocumentTx db, int documents) { + public static void loadDB(ODatabaseDocumentTx db, int documents) { - db.declareIntent(new OIntentMassiveInsert()); + db.declareIntent(new OIntentMassiveInsert()); - for (int i = 1; i <= documents; i++) { - ODocument doc = new ODocument(); - doc.setClassName("Item"); - doc = createItem(i, doc); - db.save(doc, "Item"); + for (int i = 1; i <= documents; i++) { + ODocument doc = new ODocument(); + doc.setClassName("Item"); + doc = createItem(i, doc); + db.save(doc, "Item"); - } + } - db.declareIntent(null); + db.declareIntent(null); - } + } - public static void createSchemaDB(ODatabaseDocumentTx db) { + public static void createSchemaDB(ODatabaseDocumentTx db) { - OSchema schema = db.getMetadata().getSchema(); + OSchema schema = db.getMetadata().getSchema(); - // item - OClass item = schema.createClass("Item"); + // item + OClass item = schema.createClass("Item"); - item.createProperty("stringKey", OType.STRING).createIndex(INDEX_TYPE.UNIQUE); - item.createProperty("intKey", OType.INTEGER).createIndex(INDEX_TYPE.UNIQUE); - item.createProperty("date", OType.DATE).createIndex(INDEX_TYPE.NOTUNIQUE); - item.createProperty("time", OType.DATETIME).createIndex(INDEX_TYPE.NOTUNIQUE); - item.createProperty("text", OType.STRING); - item.createProperty("length", OType.LONG).createIndex(INDEX_TYPE.NOTUNIQUE); - item.createProperty("published", OType.BOOLEAN).createIndex(INDEX_TYPE.NOTUNIQUE); - item.createProperty("title", OType.STRING).createIndex(INDEX_TYPE.NOTUNIQUE); - item.createProperty("author", OType.STRING).createIndex(INDEX_TYPE.NOTUNIQUE); - item.createProperty("tags", OType.EMBEDDEDLIST); + item.createProperty("stringKey", OType.STRING).createIndex(INDEX_TYPE.UNIQUE); + item.createProperty("intKey", OType.INTEGER).createIndex(INDEX_TYPE.UNIQUE); + item.createProperty("date", OType.DATE).createIndex(INDEX_TYPE.NOTUNIQUE); + item.createProperty("time", OType.DATETIME).createIndex(INDEX_TYPE.NOTUNIQUE); + item.createProperty("text", OType.STRING); + item.createProperty("length", OType.LONG).createIndex(INDEX_TYPE.NOTUNIQUE); + item.createProperty("published", OType.BOOLEAN).createIndex(INDEX_TYPE.NOTUNIQUE); + item.createProperty("title", OType.STRING).createIndex(INDEX_TYPE.NOTUNIQUE); + item.createProperty("author", OType.STRING).createIndex(INDEX_TYPE.NOTUNIQUE); + item.createProperty("tags", OType.EMBEDDEDLIST); - // class Article - OClass article = schema.createClass("Article"); + // class Article + OClass article = schema.createClass("Article"); - article.createProperty("uuid", OType.INTEGER).createIndex(INDEX_TYPE.UNIQUE); - article.createProperty("date", OType.DATE).createIndex(INDEX_TYPE.NOTUNIQUE); - article.createProperty("title", OType.STRING); - article.createProperty("content", OType.STRING); + article.createProperty("uuid", OType.INTEGER).createIndex(INDEX_TYPE.UNIQUE); + article.createProperty("date", OType.DATE).createIndex(INDEX_TYPE.NOTUNIQUE); + article.createProperty("title", OType.STRING); + article.createProperty("content", OType.STRING); + article.createProperty("attachment", OType.BINARY); - // author - OClass author = schema.createClass("Author"); + // author + OClass author = schema.createClass("Author"); - author.createProperty("uuid", OType.INTEGER).createIndex(INDEX_TYPE.UNIQUE); - author.createProperty("name", OType.STRING).setMin("3"); - author.createProperty("articles", OType.LINKLIST, article); + author.createProperty("uuid", OType.INTEGER).createIndex(INDEX_TYPE.UNIQUE); + author.createProperty("name", OType.STRING).setMin("3"); + author.createProperty("articles", OType.LINKLIST, article); - // link article-->author - article.createProperty("author", OType.LINK, author); + // link article-->author + article.createProperty("author", OType.LINK, author); - schema.save(); + schema.save(); - schema.reload(); + schema.reload(); - } + } - public static ODocument createItem(int id, ODocument doc) { - String itemKey = Integer.valueOf(id).toString(); + public static ODocument createItem(int id, ODocument doc) { + String itemKey = Integer.valueOf(id).toString(); - doc.setClassName("Item"); - doc.field("stringKey", itemKey); - doc.field("intKey", id); - String contents = - "OrientDB is a deeply scalable Document-Graph DBMS with the flexibility of the Document databases and the power to manage links of the Graph databases. " - + "It can work in schema-less mode, schema-full or a mix of both. Supports advanced features such as ACID Transactions, Fast Indexes, Native and SQL queries." - + " It imports and exports documents in JSON." - + " Graphs of hundreads of linked documents can be retrieved all in memory in few milliseconds without executing costly JOIN such as the Relational DBMSs do. " - + "OrientDB uses a new indexing algorithm called MVRB-Tree, derived from the Red-Black Tree and from the B+Tree with benefits of both: fast insertion and ultra fast lookup. " - + "The transactional engine can run in distributed systems supporting up to 9.223.372.036 Billions of records for the maximum capacity of 19.807.040.628.566.084 Terabytes of data distributed on multiple disks in multiple nodes. " - + "OrientDB is FREE for any use. Open Source License Apache 2.0. "; - doc.field("text", contents); - doc.field("title", "orientDB"); - doc.field("length", contents.length()); - doc.field("published", (id % 2 > 0)); - doc.field("author", "anAuthor" + id); - // doc.field("tags", asList("java", "orient", "nosql"), - // OType.EMBEDDEDLIST); - Calendar instance = Calendar.getInstance(TimeZone.getTimeZone("UTC")); + doc.setClassName("Item"); + doc.field("stringKey", itemKey); + doc.field("intKey", id); + String contents = + "OrientDB is a deeply scalable Document-Graph DBMS with the flexibility of the Document databases and the power to manage links of the Graph databases. " + + "It can work in schema-less mode, schema-full or a mix of both. Supports advanced features such as ACID Transactions, Fast Indexes, Native and SQL queries." + + " It imports and exports documents in JSON." + + " Graphs of hundreads of linked documents can be retrieved all in memory in few milliseconds without executing costly JOIN such as the Relational DBMSs do. " + + "OrientDB uses a new indexing algorithm called MVRB-Tree, derived from the Red-Black Tree and from the B+Tree with benefits of both: fast insertion and ultra fast lookup. " + + "The transactional engine can run in distributed systems supporting up to 9.223.372.036 Billions of records for the maximum capacity of 19.807.040.628.566.084 Terabytes of data distributed on multiple disks in multiple nodes. " + + "OrientDB is FREE for any use. Open Source License Apache 2.0. "; + doc.field("text", contents); + doc.field("title", "orientDB"); + doc.field("length", contents.length()); + doc.field("published", (id % 2 > 0)); + doc.field("author", "anAuthor" + id); + // doc.field("tags", asList("java", "orient", "nosql"), + // OType.EMBEDDEDLIST); + Calendar instance = Calendar.getInstance(TimeZone.getTimeZone("UTC")); - instance.add(Calendar.HOUR_OF_DAY, -id); - Date time = instance.getTime(); - doc.field("date", time, OType.DATE); - doc.field("time", time, OType.DATETIME); + instance.add(Calendar.HOUR_OF_DAY, -id); + Date time = instance.getTime(); + doc.field("date", time, OType.DATE); + doc.field("time", time, OType.DATETIME); - return doc; + return doc; - } + } } diff --git a/src/test/java/com/orientechnologies/orient/jdbc/OrientJdbcBaseTest.java b/src/test/java/com/orientechnologies/orient/jdbc/OrientJdbcBaseTest.java index dcdb23f2f0b..dae10085a8a 100644 --- a/src/test/java/com/orientechnologies/orient/jdbc/OrientJdbcBaseTest.java +++ b/src/test/java/com/orientechnologies/orient/jdbc/OrientJdbcBaseTest.java @@ -25,9 +25,7 @@ public static void loadDriver() throws ClassNotFoundException { @Before public void prepareDatabase() throws Exception { - String dbUrl = "local:./working/db/test"; - dbUrl = "memory:test"; - + String dbUrl = "memory:test"; ODatabaseDocumentTx db = new ODatabaseDocumentTx(dbUrl); String username = "admin"; diff --git a/src/test/java/com/orientechnologies/orient/jdbc/OrientJdbcDriverTest.java b/src/test/java/com/orientechnologies/orient/jdbc/OrientJdbcDriverTest.java index eecae615763..5e8f2daf861 100644 --- a/src/test/java/com/orientechnologies/orient/jdbc/OrientJdbcDriverTest.java +++ b/src/test/java/com/orientechnologies/orient/jdbc/OrientJdbcDriverTest.java @@ -7,47 +7,33 @@ import org.junit.Test; -import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx; - import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -public class OrientJdbcDriverTest { - - @Test - public void shouldAcceptsWellFormattedURLOnly() throws ClassNotFoundException, SQLException { - - Driver drv = new OrientJdbcDriver(); - - assertTrue(drv.acceptsURL("jdbc:orient:local:./working/db/test")); - - assertFalse(drv.acceptsURL("local:./working/db/test")); - } +public class OrientJdbcDriverTest extends OrientJdbcBaseTest { - @Test - public void shouldConnect() throws SQLException { - String dbUrl = "memory:test"; + @Test + public void shouldAcceptsWellFormattedURLOnly() throws ClassNotFoundException, SQLException { - ODatabaseDocumentTx db = new ODatabaseDocumentTx(dbUrl); + Driver drv = new OrientJdbcDriver(); - if (db.exists()) { - db.open("admin", "admin"); - db.drop(); - db.close(); - } + assertTrue(drv.acceptsURL("jdbc:orient:local:./working/db/test")); - db.create(); + assertFalse(drv.acceptsURL("local:./working/db/test")); + } - Properties info = new Properties(); - info.put("user", "admin"); - info.put("password", "admin"); + @Test + public void shouldConnect() throws SQLException { - OrientJdbcConnection conn = (OrientJdbcConnection) DriverManager.getConnection("jdbc:orient:" + dbUrl, info); + Properties info = new Properties(); + info.put("user", "admin"); + info.put("password", "admin"); - assertNotNull(conn); - conn.close(); - assertTrue(conn.isClosed()); - } + OrientJdbcConnection conn = (OrientJdbcConnection) DriverManager.getConnection("jdbc:orient:memory:test", info); + assertNotNull(conn); + conn.close(); + assertTrue(conn.isClosed()); + } } diff --git a/src/test/java/com/orientechnologies/orient/jdbc/OrientJdbcStatementDMLtest.java b/src/test/java/com/orientechnologies/orient/jdbc/OrientJdbcStatementDMLtest.java index fdf7a872053..1a2ccb16b94 100644 --- a/src/test/java/com/orientechnologies/orient/jdbc/OrientJdbcStatementDMLtest.java +++ b/src/test/java/com/orientechnologies/orient/jdbc/OrientJdbcStatementDMLtest.java @@ -21,105 +21,105 @@ public class OrientJdbcStatementDMLtest extends OrientJdbcBaseTest { - @Test - public void shouldInsertANewItem() throws Exception { + @Test + public void shouldInsertANewItem() throws Exception { - assertFalse(conn.isClosed()); - Date date = new Date(System.currentTimeMillis()); + assertFalse(conn.isClosed()); + Date date = new Date(System.currentTimeMillis()); - Statement stmt = conn.createStatement(); - int updated = stmt.executeUpdate("INSERT into Item (stringKey, intKey, text, length, date) values ('100','100','dummy text','10','" + date.toString() + "')"); + Statement stmt = conn.createStatement(); + int updated = stmt.executeUpdate("INSERT into Item (stringKey, intKey, text, length, date) values ('100','100','dummy text','10','" + date.toString() + "')"); - assertEquals(1, updated); + assertEquals(1, updated); - stmt = conn.createStatement(); - ResultSet rs = stmt.executeQuery("SELECT stringKey, intKey, text, length, date FROM Item where intKey = '100' "); - rs.next(); - assertEquals(100, rs.getInt("intKey")); - assertEquals("100", rs.getString("stringKey")); - assertEquals(date.toString(), rs.getDate("date").toString()); + stmt = conn.createStatement(); + ResultSet rs = stmt.executeQuery("SELECT stringKey, intKey, text, length, date FROM Item where intKey = '100' "); + rs.next(); + assertEquals(100, rs.getInt("intKey")); + assertEquals("100", rs.getString("stringKey")); + assertEquals(date.toString(), rs.getDate("date").toString()); - } + } - @Test - public void shouldUpdateAnItem() throws Exception { + @Test + public void shouldUpdateAnItem() throws Exception { - assertFalse(conn.isClosed()); + assertFalse(conn.isClosed()); - Statement stmt = conn.createStatement(); - int updated = stmt.executeUpdate("UPDATE Item set text = 'UPDATED' WHERE intKey = '10'"); + Statement stmt = conn.createStatement(); + int updated = stmt.executeUpdate("UPDATE Item set text = 'UPDATED' WHERE intKey = '10'"); - assertFalse(stmt.getMoreResults()); - assertEquals(1, updated); + assertFalse(stmt.getMoreResults()); + assertEquals(1, updated); - stmt = conn.createStatement(); - ResultSet rs = stmt.executeQuery("SELECT stringKey, intKey, text, length, date FROM Item where intKey = '10' "); - rs.next(); - assertEquals("UPDATED", rs.getString("text")); + stmt = conn.createStatement(); + ResultSet rs = stmt.executeQuery("SELECT stringKey, intKey, text, length, date FROM Item where intKey = '10' "); + rs.next(); + assertEquals("UPDATED", rs.getString("text")); - } + } - @Test - public void shouldDeleteAnItem() throws Exception { + @Test + public void shouldDeleteAnItem() throws Exception { - assertFalse(conn.isClosed()); + assertFalse(conn.isClosed()); - Statement stmt = conn.createStatement(); - int updated = stmt.executeUpdate("DELETE FROM Item WHERE intKey = '10'"); + Statement stmt = conn.createStatement(); + int updated = stmt.executeUpdate("DELETE FROM Item WHERE intKey = '10'"); - assertFalse(stmt.getMoreResults()); - assertEquals(1, updated); + assertFalse(stmt.getMoreResults()); + assertEquals(1, updated); - stmt = conn.createStatement(); - ResultSet rs = stmt.executeQuery("SELECT stringKey, intKey, text, length, date FROM Item where intKey = '10' "); - assertFalse(rs.next()); + stmt = conn.createStatement(); + ResultSet rs = stmt.executeQuery("SELECT stringKey, intKey, text, length, date FROM Item where intKey = '10' "); + assertFalse(rs.next()); - } + } - @Test - public void shoulCreateClassWithProperties() throws IOException, SQLException { + @Test + public void shoulCreateClassWithProperties() throws IOException, SQLException { - Statement stmt = conn.createStatement(); + Statement stmt = conn.createStatement(); - stmt.executeUpdate("CREATE CLASS Account "); - stmt.executeUpdate("CREATE PROPERTY Account.id INTEGER "); - stmt.executeUpdate("CREATE PROPERTY Account.birthDate DATE "); - stmt.executeUpdate("CREATE PROPERTY Account.binary BINARY "); - stmt.close(); + stmt.executeUpdate("CREATE CLASS Account "); + stmt.executeUpdate("CREATE PROPERTY Account.id INTEGER "); + stmt.executeUpdate("CREATE PROPERTY Account.birthDate DATE "); + stmt.executeUpdate("CREATE PROPERTY Account.binary BINARY "); + stmt.close(); - // double value test pattern? - ODatabaseDocumentTx database = conn.getDatabase(); - assertThat(database.getClusterIdByName("account"), notNullValue()); - OClass account = database.getMetadata().getSchema().getClass("Account"); - assertThat(account, notNullValue()); - assertThat(account.getProperty("id").getType(), equalTo(OType.INTEGER)); - assertThat(account.getProperty("birthDate").getType(), equalTo(OType.DATE)); - assertThat(account.getProperty("binary").getType(), equalTo(OType.BINARY)); + // double value test pattern? + ODatabaseDocumentTx database = conn.getDatabase(); + assertThat(database.getClusterIdByName("account"), notNullValue()); + OClass account = database.getMetadata().getSchema().getClass("Account"); + assertThat(account, notNullValue()); + assertThat(account.getProperty("id").getType(), equalTo(OType.INTEGER)); + assertThat(account.getProperty("birthDate").getType(), equalTo(OType.DATE)); + assertThat(account.getProperty("binary").getType(), equalTo(OType.BINARY)); - } + } - @Test - public void shoulCreateClassWithBatchCommand() throws IOException, SQLException { + @Test + public void shoulCreateClassWithBatchCommand() throws IOException, SQLException { - Statement stmt = conn.createStatement(); + Statement stmt = conn.createStatement(); - stmt.addBatch("CREATE CLASS Account "); - stmt.addBatch("CREATE PROPERTY Account.id INTEGER "); - stmt.addBatch("CREATE PROPERTY Account.birthDate DATE "); - stmt.addBatch("CREATE PROPERTY Account.binary BINARY "); - int[] results = stmt.executeBatch(); - assertThat(results.length, equalTo(4)); - stmt.close(); + stmt.addBatch("CREATE CLASS Account "); + stmt.addBatch("CREATE PROPERTY Account.id INTEGER "); + stmt.addBatch("CREATE PROPERTY Account.birthDate DATE "); + stmt.addBatch("CREATE PROPERTY Account.binary BINARY "); + int[] results = stmt.executeBatch(); + assertThat(results.length, equalTo(4)); + stmt.close(); - // double value test pattern? - ODatabaseDocumentTx database = conn.getDatabase(); - assertThat(database.getClusterIdByName("account"), notNullValue()); - OClass account = database.getMetadata().getSchema().getClass("Account"); - assertThat(account, notNullValue()); - assertThat(account.getProperty("id").getType(), equalTo(OType.INTEGER)); - assertThat(account.getProperty("birthDate").getType(), equalTo(OType.DATE)); - assertThat(account.getProperty("binary").getType(), equalTo(OType.BINARY)); + // double value test pattern? + ODatabaseDocumentTx database = conn.getDatabase(); + assertThat(database.getClusterIdByName("account"), notNullValue()); + OClass account = database.getMetadata().getSchema().getClass("Account"); + assertThat(account, notNullValue()); + assertThat(account.getProperty("id").getType(), equalTo(OType.INTEGER)); + assertThat(account.getProperty("birthDate").getType(), equalTo(OType.DATE)); + assertThat(account.getProperty("binary").getType(), equalTo(OType.BINARY)); - } + } }