How to add column to CachedRowSet in java 7?

559 views Asked by At

I want to append a new column in the fashion of

public CachedRowSet addColumn(cachedRowSet Original,List<item> column, String columnName);

or

public CachedRowSet addColumn(cachedRowSet Original,int column,String columnName);

with the column value repeated if it is a primitive.

What is the best way to do this?

2

There are 2 answers

1
eckes On BEST ANSWER

Hmm.. hard to answer without knowing the context. Who is providing that CachedRowSet? They might or might not offer a way to generate a new instance. Are you using CachedRowSetImpl from the RI?

The RowSet is not really intended for that. Can you add it to the generating SQL? SELECT a,b,'additional' from .... Or you can use your CachedRowSet and generate JoinedRowSet with a FULL_JOIN with a single field result set.

0
user207421 On

You can't do that in SQL, let alone CachedRowSet, without executing DDL, and CachedRowSet doesn't support that. The part about a repeating value is an elementary violation of 3NF. You probably don't want to do any of this.