• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

JDBC RowSet (K&B)  RSS feed

 
Greenhorn
Posts: 7
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Question
Why A,B,E are incorrect?How they are Disconnected RowSet Object?
 
author & internet detective
Posts: 38921
686
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What book or website is that question from?
 
Nilesh Garje
Greenhorn
Posts: 7
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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


K&B OCP7
chapter-15
page number-940
Question Number-11
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!