Friday 23 August 2013

WebRowSet and its SyncProvider

WebRowSet and its SyncProvider

They say from this API that:
A WebRowSet implementation is created with an RIXMLProvider by default.
WebRowSet wrs = new FooWebRowSetImpl();
The SyncFactory always provides an instance of RIOptimisticProvider when
no provider is specified, but the implementation of the default
constructor for WebRowSet sets the provider to be the RIXMLProvider
implementation. Therefore, the following line of code is executed behind
the scenes as part of the implementation of the default constructor.
wrs.setSyncProvider("com.sun.rowset.providers.RIXMLProvider");
I would say it's not true. I have checked it by doing the following:
WebRowSet webR = new WebRowSetImpl();
webR.setUsername("root");
webR.setPassword("RanchingAround");
webR.setUrl("jdbc:mysql://localhost:3306/test");
webR.setCommand("SELECT * FROM books");
webR.execute();
System.out.println(webR.getSyncProvider());
webR.absolute(1);
webR.updateString(2, "Indeed it is");
webR.updateRow();
System.out.println(webR.getSyncProvider());
FileOutputStream fo = new
FileOutputStream("/home/widelec/Desktop/File.xml");
webR.writeXml(fo);
The output of getSyncProvider both before and after accessing the database
is RIOptimisticProvider. It should have been RIXMLProvider...
Anybody knows why it happens like that? Again for an OCPJP7 question I
would not know what to choose if asked since the tutorial and API say a
thing and the reality is another.
What do you think.. is it a bug in my code? Could you please try it out to
see if you get the same result?
Thanks in advance.

No comments:

Post a Comment