/** @throws Exception */
 public void testHandle() throws Exception {
   String sql = "select empno, ename from emp where empno = ?";
   DataTable table = new DataTableImpl("emp");
   table.addColumn("empno").setPrimaryKey(true);
   table.addColumn("ename");
   DataRow row = table.addRow();
   row.setValue("empno", new BigDecimal(7788));
   row.setValue("ename", "SCOTT");
   DataTable newTable = new DataTableImpl("emp");
   newTable.addColumn("empno").setPrimaryKey(true);
   newTable.addColumn("ename");
   DataRow newRow = newTable.addRow();
   SelectHandler handler =
       new BasicSelectHandler(ds_, sql, new DataRowReloadResultSetHandler(newRow));
   handler.execute(new Object[] {new Integer(7788)});
   System.out.println(newRow);
   assertEquals("2", row, newRow);
 }
 /** @throws Exception */
 public void testHandle2() throws Exception {
   String sql = "select dept_no, d_name from dept3 where dept_no = ?";
   DataTable table = new DataTableImpl("dept3");
   table.addColumn("dept_no").setPrimaryKey(true);
   table.addColumn("d_name");
   DataRow row = table.addRow();
   row.setValue("dept_no", new BigDecimal(20));
   row.setValue("d_name", "RESEARCH");
   DataTable newTable = new DataTableImpl("dept3");
   newTable.addColumn("dept_no").setPrimaryKey(true);
   newTable.addColumn("d_name");
   DataRow newRow = newTable.addRow();
   SelectHandler handler =
       new BasicSelectHandler(ds_, sql, new DataRowReloadResultSetHandler(newRow));
   handler.execute(new Object[] {new Integer(20)});
   System.out.println(newRow);
   assertEquals(row, newRow);
 }
Ejemplo n.º 3
0
 public DataTable read() {
   DataTable newTable = new DataTableImpl(table.getTableName());
   for (int i = 0; i < table.getColumnSize(); ++i) {
     DataColumn column = table.getColumn(i);
     newTable.addColumn(column.getColumnName(), column.getColumnType());
   }
   for (int i = 0; i < table.getRowSize(); ++i) {
     DataRow row = table.getRow(i);
     DataRow newRow = newTable.addRow();
     reload(row, newRow);
   }
   return newTable;
 }