• 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:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

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
Marshal
Posts: 38508
653
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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!