Package org.apache.metamodel.jdbc

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


                }
            });

            Table table = schema.getTableByName("my_table");
            Query query = dc.query().from(table).selectCount().toQuery();
            DataSet ds = dc.executeQuery(query);
            assertTrue(ds.next());
            assertEquals("Row[values=[1000000]]", ds.getRow().toString());
            assertFalse(ds.next());
            ds.close();
        } finally {
View Full Code Here


        }
      });

      Table table = schema.getTableByName("my_table");
      Query query = dc.query().from(table).selectCount().toQuery();
      DataSet ds = dc.executeQuery(query);
      ds.close();
    } catch (ClassNotFoundException e) {
      e.printStackTrace();
    } catch (SQLException e) {
      e.printStackTrace();
View Full Code Here

    assertEquals("[Schema[name=mysql], Schema[name=performance_schema], Schema[name=portal], "
        + "Schema[name=sakila], Schema[name=world]]", Arrays.toString(schemas));

    Table table = dc.getSchemaByName("sakila").getTableByName("film");
    Query q = new Query().from(table).select(table.getColumns());
    DataSet data = dc.executeQuery(q);
    TableModel tableModel = new DataSetTableModel(data);
    assertEquals(13, tableModel.getColumnCount());
    assertEquals(1000, tableModel.getRowCount());
  }
View Full Code Here

        q.toString());
    FilterItem f1 = new FilterItem(q.getSelectClause().getItem(0), OperatorType.EQUALS_TO, 5);
    FilterItem f2 = new FilterItem(q.getSelectClause().getItem(0), OperatorType.EQUALS_TO, 8);
    q.where(new FilterItem(f1, f2));

    DataSet dataSet = dc.executeQuery(q);
    TableModel tableModel = new DataSetTableModel(dataSet);
    assertEquals(4, tableModel.getColumnCount());
    assertEquals(2, tableModel.getRowCount());
    assertEquals("LOLLOBRIGIDA", tableModel.getValueAt(0, 2));
View Full Code Here

    assertEquals(4, tableModel.getColumnCount());
    assertEquals(2, tableModel.getRowCount());
    assertEquals("LOLLOBRIGIDA", tableModel.getValueAt(0, 2));

    q.setMaxRows(1);
    dataSet = dc.executeQuery(q);
    tableModel = new DataSetTableModel(dataSet);
    assertEquals(4, tableModel.getColumnCount());
    assertEquals(1, tableModel.getRowCount());
    assertEquals("LOLLOBRIGIDA", tableModel.getValueAt(0, 2));
   
View Full Code Here

    assertEquals(1, tableModel.getRowCount());
    assertEquals("LOLLOBRIGIDA", tableModel.getValueAt(0, 2));
   
    q.setMaxRows(1);
    q.setFirstRow(2);
        dataSet = dc.executeQuery(q);
        tableModel = new DataSetTableModel(dataSet);
        assertEquals(4, tableModel.getColumnCount());
        assertEquals(1, tableModel.getRowCount());
        assertEquals("JOHANSSON", tableModel.getValueAt(0, 2));
View Full Code Here

        assertEquals("JOHANSSON", tableModel.getValueAt(0, 2));

    q.getWhereClause().removeItems();
    q.setMaxRows(25);
    q.setFirstRow(1);
    dataSet = dc.executeQuery(q);
    tableModel = new DataSetTableModel(dataSet);
    assertEquals(4, tableModel.getColumnCount());
    assertEquals(25, tableModel.getRowCount());
    assertEquals("GUINESS", tableModel.getValueAt(0, 2).toString());
  }
View Full Code Here

  // Test to query the film table (caused troubles in DataCleaner)
  public void testFilmQuery() throws Exception {
    DataContext dc = new JdbcDataContext(_connection);
    Table table = dc.getDefaultSchema().getTableByName("film");
    Query q = new Query().select(table.getColumns()).from(table).setMaxRows(400);
    dc.executeQuery(q);
  }

  public void testGetSchema() throws Exception {
    DataContext dc = new JdbcDataContext(_connection);
    Schema[] schemas = dc.getSchemas();
View Full Code Here

  }

  public void testQueryWithSingleQuote() throws Exception {
    DataContext dc = new JdbcDataContext(_connection, TableType.DEFAULT_TABLE_TYPES, "sakila");
    Query q = dc.query().from("category").selectCount().where("name").eq("kasper's horror movies").toQuery();
    DataSet ds = dc.executeQuery(q);
    assertTrue(ds.next());
    assertEquals(0, ((Number) ds.getRow().getValue(0)).intValue());
    assertFalse(ds.next());
  }
View Full Code Here

        Query query = dc.query().from(countryTable).select("COUNTRYCODE").limit(200).toQuery();
        assertEquals("SELECT DB2INST1.\"COUNTRY\".\"COUNTRYCODE\" FROM DB2INST1.\"COUNTRY\" "
                + "FETCH FIRST 200 ROWS ONLY", dc.getQueryRewriter().rewriteQuery(query));

        DataSet ds = dc.executeQuery(query);
        for (int i = 0; i < 200; i++) {
            assertTrue(ds.next());
            assertEquals(1, ds.getRow().getValues().length);
        }
        assertFalse(ds.next());
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.