26286 total geeks with 3498 solutions
Recent challengers:
 Welcome, you are an anonymous user! [register] [login] Get a yourname@osix.net email address 

Articles

GEEK

User's box
Username:
Password:

Forgot password?
New account

Shoutbox
MaxMouse
It's Friday... That's good enough for me!
CodeX
non stop lolz here but thats soon to end thanks to uni, surely the rest of the world is going good?
stabat
how things are going guys? Here... boring...
CodeX
I must be going wrong on the password lengths then, as long as it was done on ECB
MaxMouse
lol... the key is in hex (MD5: of the string "doit" without the "'s) and is in lower case. Maybe i should have submitted this as a challenge!

Donate
Donate and help us fund new challenges
Donate!
Due Date: May 31
May Goal: $40.00
Gross: $0.00
Net Balance: $0.00
Left to go: $40.00
Contributors


News Feeds
The Register
Twitter locks down
logins by adding
two-factor
authentication
IiNet offloads
fibre network to
NBN Co
Microsoft tweaks
WinPhone YouTube
app to fix Google
gripes
Ethernet daddy:
online education
poised to transform
the world
More than half of
Windows 8 users
just treat it like
Windows 7
Press exposure of
Federal data
security hole leads
to legal threats
Big Brother
security tech gets
$20m
Speaking in Tech:
Portland hipsters
gagging for
yesterday"s web
tool
Citrix halfway to
Avalon with
XenDesktop 7
desktop and app
virtualizer
Sony"s board
debates breaking up
with
Spider-Man
Slashdot
Rough Roving:
Curiosity"s Wheels
Show Damage
Tesla Motors Repays
$465M Government
Loan 9 Years Early
Why the "Star Trek
Computer" Will Be
Open Source and
Apache Licensed
NYPD Detective
Accused of Hiring
Email Hackers
Scientists Find
Vitamin C Kills
Drug-Resistant
Tuberculosis
German IT Firm
Seeks Autistic
Workers
Violent Galactic
Clash May Solve
Cosmic Mystery
The Canadian
Government"s War On
Science
MariaDB vs. MySQL:
A Performance
Comparison
Will Robots Take
Over the Data
Center?
Article viewer

Rowset a Java-Bean Compliant Object that Encapsulates Database Access



Written by:sharad_thakur007
Published by:Nightscript
Published on:2005-10-13 07:28:17
Topic:Java
Search OSI about Java.More articles by sharad_thakur007.
 viewed 9602 times send this article printer friendly

Digg this!
    Rate this article :
Rowset is a Java-Bean Compliant Object that Encapsulates Database Access.

Rowset is a Java-Bean Compliant Object that Encapsulates Database Access.

In Rowset we only have to create a single object rather than the typical 3 objects - Connection(for creating connection), Statement(for query execution), ResultSet (to get the Result).

Apart from this encapsulation Rowset object can be used as a java-bean component. As a bean, a rowset provides a set of mutators for setting properties and a complementary set of accessors to get the values of these properties. Rowset also supports JAVABEAN style events. Rowset object generates events when certain changes occurs in the state of the Rowset. Interested objects can register themselves as listeners for these events and be notified as event occurs[provide event listeners like AWT & Swings].

Rwset.setCommand(“sql”);
Rwset.setURl(“ ”);
Rwset.setUserName(“”);
Rwset.setPassWord(“”);
Rwset.execute()


Besides providing properties it also encapsulates a set of row(s) [Results].Resultset offers a wide variety of methods to access result set rows and corresponding fields.

There are 3 types of rowset objects. These are actual implementation of Rowset Interface. These implementations are not part of Core Api or JDBC Api.

  • Cached Rowset
  • JDBC Rowset
  • Web Rowset


The JDBC Rowset is a connected approach [unless u don’t use close() method] and is not serializable.

1. Cached Rowset extends BaseRowset implements Rowset, Rowsetinternal, Cloneable, Serializable

It is a disconnected, serializable, cloneable and scrollable container for rows of data.
It is disconnected and therefore doesn’t hold a connection object. Since it is serializable and cloneable, we can create copies of our cached Rowset and transfer them across the wire. For instance an ejb component can create and return a cached rowset
to the client across the network. The client can modify the Rowset and send it back to the component and component can perform updates.

Use :
1. If client application intends to hold the connection for long time intervals.
2. Client has neither capacity nor resources for connecting to database. For instance Networked Devices such as PDAs & other thin clients do not have resources to connect to the databases. In such cases, a server side application can create a cached rowset, and send it across the network to the thin client. The client can scroll thru the rowset and may also save it for later use.the client can send a copy of the result back to the server side application whenever it updates it. In effect the cached rowset gives the ability to create a “Downlodable Resultset”. creation of cachced rowset is similar to rowset code and it also all methods of Resultset.actually updatexxx() methods are there.

CachedRowSet cr=new CachedRowSet()
Cr.setUser,pass,command
Cr.execute();
While (cr.next)
{
    statements
}


Since the cached rowset is disconnected, to update the Database cr.acceptChanges() method is there. It re-establishes the connection to the database & makes the necessary updates to the database.this method throws SQLEXception in case of Failures while making changes.

2. JDBC Rowset implements Rowset

It is a connected Rowset.purpose of the jdbc Rowset is to provide a JAVABEANS type layer on top of java.sql.Resultset.unlike a cached rowset, a jdbc rowset is connected,is not serializable andnor cloneable. It provides whatever features the underlying Resultset interface provides, with the added advantage of presenting itself like a java-bean.

3. Web Rowset extends Cached Rowset

It is intended for web-based applications. It communicates with other components by the use of XML over HTTP Protocol not over TCP-IP based DATABASE protocols.
A web client (possibly with java-script or java support) retrieves a set of result(s) using webrowset Object. When the webrowset object’s execute method is called, it calls a servlet on the server-side (which performs database access) to populate the resultset.once the rowset is updated , the webrowset object sends the updated data to a server side implementation of the rowset as xmldata over HTTP Protocol. The server side implementation then updates the database. Webrowset objects use incremental caching of data.so that data can be retrieved in chunks.as the client browses thru the webrowset,additional data is downloaded from the server side.

When the web client creates a webrowset and executes a command,the client side implementation of webrowset send this request to the server side implementation of over HTTP.The server side implementation would connect to the database, execute the command and populate the Rowset. The server side implementation would then write the data in to an xml document & sends it back to the client implementation over HTTP. This process is repeated when client modifies the rowset and call AcceptChanges. The client side implementation would send an xml copy of the webrowset to the server side implementation over HTTP and the server side implementation would perform actual updates.

Using the WebRowset eliminates the need for the client to connect to the database server on the internet.if there is a facility to connect to the database sever from client (however proxies & fire walls allow this) there will be a security threat.in order to avoid this server side implementation of webrowset Object would act as a proxy for the database.therefore client side implementation uses the server-side implementation to retrieve & update results.The main implication of this architecture is that it makes the database clients thin & clients can use the HTTP protocol [INSTEAD OF TCP-IP BASED DATABASE PROTOCOLS].


Conclusions

Actually there will be client side and server side implementation (work as a proxy for database access) which will be by default available. Whenever a client will create a WEBROWSET object and fire the execute() method on it, it will call the client side implementation(Proxy for client to access the server) of WEBROWSET object that will call the server side implementation that will actually perform the database access and render the WEBRowset and then will write data in to XML Document and send it back to the client side implementation over HTTP, and similar process will be repeated when client modifies the rowset object and call accept changes.the client side implementation would send an xml copy of the webrowset to the server-side implementation over HTTP and the server side implementation would perform actual updates.

Did you like this article? There are hundreds more.

Comments:
<none>
Anonymously add a comment: (or register here)
(registration is really fast and we send you no spam)
BB Code is enabled.
Captcha Number:


Blogs: (People who have posted blogs on this subject..)
goldie
using javamail i am getting excetion like this on Tue 5th May 6am
avax.mail.MessagingException: Unknown SMTP host: pop3.gmail.com; nested exception is: java.net.UnknownHostException: pop3.gmail.com at com.sun.mail.smtp.SMTPTransport.openServ er(SMTPTransport.java:1543) at com.sun.mail.smtp.SMTPTransport.protocol
kdemetter
Blog entry for Wed 11th Apr 1pm on Wed 11th Apr 1pm
lately i've been playing with Java a little . I'm working on a application that can create a list of meals for one week from a large list of meals . well , it works . just some problems with Swing not doing what i want it to do :-) http://www.os

Test Yourself: (why not try testing your skill on this subject? Clicking the link will start the test.)
Java tricks by berry120

Think you really know Java? This won't test you on elaborate and never heard of APIs. It will test you on stuff that isn't always as it seems...
Java Programming - Level 1 by D-Cypell

A first level Java programming test. The test contains 10 questions on Java syntax, concepts and the API.
History and Basic Programming Knowledge by HackMaster321

A test of your knowledge of java history and programming. Tests your ability to recall java historical facts, and remember what some of javas more common commands and syntax are and do.


     
Your Ad Here
 
Copyright Open Source Institute, 2006