Forums Register Login
JDBC RowSet (K&B)
Which creates a connected RowSet object?
A. WebRowSet wrs = RowSetProvider.newFactory().createWebRowSet();
B. CachedRowSet crs = RowSetProvider.newFactory().createCachedRowSet();
C. try(JdbcRowSet jrs = RowSetProvider.newFactory().createJdbcRowSet()) {
// assume the rest of the try-catch is valid
D. try(RowSetFactory rsf = RowSetProvider.newFactory()) {
RowSet rws = rsf.createRowSet();
// assume the rest of the try-catch is valid
E. JoinRowSet jrs = RowSetProvider.newFactory().createJoinRowSet();
F. ResultSet rs = Statement.execute("SELECT * FROM Customer");
JdbcRowSet jrs = RowSetProvider.newFactory().setResultSet(rs);
Ans :
☑ C is the correct answer. This code fragment is creating an instance of a JdbcRowSet
object—the only RowSet that is a connected RowSet object. This is the proper way to use the
RowSetProvider static newFactory() method or obtain a RowSetFactory instance that is
then used to create a JdbcRowSet instance.
☐✗ A, B, and E are incorrect. These are disconnected RowSet objects, although the syntax
to acquire these objects is correct. D is incorrect and will not compile. The reason is that
RowSetFactory does not extend AutoCloseable; thus, the compiler will complain about the
use of RowSetFactory in a try-with-resources. F is incorrect because this is not the proper way
to initialize a RowSet object. The factory method is used to create an instance, and the instance
must be used to execute a query and populate the RowSet with results.
Why A,B,E are incorrect?How they are Disconnected RowSet Object?
What book or website is that question from?

Jeanne Boyarsky wrote:What book or website is that question from?

hi Jeanne,
    I read  question  wrongly "Which creates a disconnected RowSet object?" but actual question is "Which creates a connected RowSet object?".

Thanks ! for replay

page number-940
Question Number-11
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
Thread Boost - a very different sort of advertising

This thread has been viewed 159 times.

All times above are in ranch (not your local) time.
The current ranch time is
Apr 23, 2018 03:51:05.