Package org.apache.metamodel.jdbc

Examples of org.apache.metamodel.jdbc.JdbcDataContext.executeUpdate()


                    "Could not execute batch: INSERT INTO \"public\".\"my_table\" (\"person name\",age) VALUES ('John Doe','42'): Batch entry 0 INSERT INTO \"public\".\"my_table\" (\"person name\",age) VALUES ('John Doe','42') was aborted.  Call getNextException to see the cause.",
                    e.getMessage());
        } finally {
            dc.refreshSchemas();
            if (dc.getTableByQualifiedLabel("my_table") != null) {
                dc.executeUpdate(new UpdateScript() {
                    @Override
                    public void run(UpdateCallback cb) {
                        cb.dropTable("my_table").execute();
                    }
                });
View Full Code Here


    public void testCreateTableAndInsert1MRecords() throws Exception {
        JdbcDataContext dc = new JdbcDataContext(_connection);
        final Schema schema = dc.getDefaultSchema();
        try {
            dc.executeUpdate(new UpdateScript() {
                @Override
                public void run(UpdateCallback cb) {
                    Table table = cb.createTable(schema, "my_table").withColumn("id").ofType(ColumnType.INTEGER)
                            .ofNativeType("SERIAL").nullable(false).withColumn("person name").ofSize(255)
                            .withColumn("age").ofType(ColumnType.INTEGER).execute();
View Full Code Here

            assertTrue(ds.next());
            assertEquals("Row[values=[1000000]]", ds.getRow().toString());
            assertFalse(ds.next());
            ds.close();
        } finally {
            dc.executeUpdate(new UpdateScript() {
                @Override
                public void run(UpdateCallback cb) {
                    cb.dropTable("my_table").execute();
                }
            });
View Full Code Here

    JdbcDataContext dc = new JdbcDataContext(_connection);
    final Schema schema = dc.getSchemaByName("Person");
    assertEquals("Person", schema.getName());

    dc.executeUpdate(new UpdateScript() {
      @Override
      public void run(UpdateCallback cb) {
        Table table = cb.createTable(schema, "test_table").withColumn("id").asPrimaryKey()
            .ofType(ColumnType.INTEGER).withColumn("birthdate").ofType(ColumnType.DATE).execute();
View Full Code Here

    JdbcDataContext dc = new JdbcDataContext(_connection);
    final Schema schema = dc.getDefaultSchema();
    assertEquals("sakila", schema.getName());

    dc.executeUpdate(new UpdateScript() {
      @Override
      public void run(UpdateCallback cb) {
        Table table = cb.createTable(schema, "test_table").withColumn("id").ofType(ColumnType.INTEGER)
            .asPrimaryKey().withColumn("birthdate").ofType(ColumnType.DATE).execute();
View Full Code Here

    assertEquals("Row[values=[2, 2011-12-21]]", ds.getRow().toString());
    assertEquals("java.sql.Date", ds.getRow().getValue(1).getClass().getName());
    assertFalse(ds.next());
    ds.close();

    dc.executeUpdate(new UpdateScript() {
      @Override
      public void run(UpdateCallback callback) {
        callback.dropTable("test_table").execute();
      }
    });
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.