Package org.apache.metamodel.jdbc

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


            assertEquals("Row[values=[2, Jane Doe, 44]]", 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(getConnection());
        final Schema schema = dc.getDefaultSchema();
        try {
            dc.executeUpdate(new BatchUpdateScript() {
                @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

                    "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.",
                    message);
        } 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

        }

        JdbcDataContext dc = new JdbcDataContext(getConnection());
        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

      connection = DriverManager.getConnection(CONNECTION_STRING,
          USERNAME, PASSWORD);

      JdbcDataContext dc = new JdbcDataContext(connection);
      final Schema schema = dc.getDefaultSchema();
      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)
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

    private JdbcDataContext createLimitAndOffsetTestData() {
        final JdbcDataContext dc = new JdbcDataContext(_connection);

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

                    callback.dropTable("test_table").execute();
                }
            });
        }

        dc.executeUpdate(new UpdateScript() {
            @Override
            public void run(UpdateCallback callback) {
                Table table = callback.createTable(dc.getDefaultSchema(), "test_table").withColumn("foo")
                        .ofType(ColumnType.INTEGER).withColumn("bar").ofType(ColumnType.VARCHAR).execute();
                callback.insertInto(table).value("foo", 1).value("bar", "hello").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.