private void setup() { StringBuffer buf = new StringBuffer(100); buf.append("SELECT "); StringBuffer whereBuf = new StringBuffer(100); whereBuf.append(" WHERE"); List primaryKeyList = new ArrayList(); for (int i = 0; i < table.getColumnSize(); ++i) { DataColumn column = table.getColumn(i); buf.append(column.getColumnName()); buf.append(", "); if (column.isPrimaryKey()) { whereBuf.append(" "); whereBuf.append(column.getColumnName()); whereBuf.append(" = ? AND"); primaryKeyList.add(column.getColumnName()); } } buf.setLength(buf.length() - 2); whereBuf.setLength(whereBuf.length() - 4); buf.append(" FROM "); buf.append(table.getTableName()); buf.append(whereBuf); sql = buf.toString(); primaryKeys = (String[]) primaryKeyList.toArray(new String[primaryKeyList.size()]); }
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; }