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(_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

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

    public void testBoolean() throws Exception {
        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("some_bool").ofType(ColumnType.BOOLEAN)
                        .nullable(false).execute();
View Full Code Here

        assertEquals("Row[values=[true]]", ds.getRow().toString());
        assertTrue(ds.next());
        assertEquals("Row[values=[false]]", ds.getRow().toString());
        assertFalse(ds.next());

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

    public void testBlob() throws Exception {
        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("some_bytes").ofType(ColumnType.BLOB)
                        .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.