Package org.apache.metamodel.jdbc

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


        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(getConnection());
    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(getConnection());

        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

        JdbcDataContext dc = new JdbcDataContext(connection);
        final Schema schema = dc.getDefaultSchema();

        // create table
        dc.executeUpdate(new UpdateScript() {
            @Override
            public void run(UpdateCallback cb) {
                Table table = cb.createTable(schema, "my_table").withColumn("id").asPrimaryKey()
                        .ofType(ColumnType.INTEGER).ofNativeType("SERIAL").nullable(false).withColumn("name")
                        .ofType(ColumnType.VARCHAR).ofSize(10).withColumn("foo").ofType(ColumnType.BOOLEAN)
View Full Code Here

        assertTrue(dc.getColumnByQualifiedLabel("my_table.id").isPrimaryKey());
        assertFalse(dc.getColumnByQualifiedLabel("my_table.name").isPrimaryKey());

        // insert records
        dc.executeUpdate(new UpdateScript() {
            @Override
            public void run(UpdateCallback callback) {
                RowInsertionBuilder builder = callback.insertInto("my_table").value("name", "row 1").value("foo", true);

                try {
View Full Code Here

        assertEquals("Row[values=[row 1]]", ds.getRow().toString());
        assertFalse(ds.next());
        ds.close();

        // drop
        dc.executeUpdate(new UpdateScript() {

            @Override
            public void run(UpdateCallback callback) {
                callback.dropTable("my_table").execute();
            }
View Full Code Here

        }

        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).withColumn("name").ofType(ColumnType.VARCHAR)
                        .ofSize(10).withColumn("foo").ofType(ColumnType.BOOLEAN).nullable(true).withColumn("bar")
View Full Code Here

                assertEquals("my_table", table.getName());
            }
        });

        try {
            dc.executeUpdate(new UpdateScript() {
                @Override
                public void run(UpdateCallback callback) {
                    callback.insertInto("my_table").value("name", "row 1").value("foo", true).execute();

                    callback.insertInto("my_table").value("name", "row 2").value("bar", true).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.