Create a CachedRowSet The CachedRowSet is, in fact, a JavaBean. It supports properties that allow it to connect to a database and retrieve data on its own. The table below describes some of the properties necessary to initialize a CachedRowSet without a pre-existing database connection: CachedRowSet database connection properties Property DescriptionUsername Database username Password Database user password URL Database JDBC URL such as jdbc:odbc:mydsn Command SQL query statement Because it is a JavaBean, you can simply use the default constructor when creating a new instance of the CachedRowSet object: CachedRowSet crs = new CachedRowSet(); <jsp:useBean id="Contacts" class="sun.jdbc.rowset.CachedRowSet" scope="session"> <% // load database driver Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); // initialize our CachedRowSet bean Contacts.setUsername("dbuser"); // example userid Contacts.setPassword("dbpassword"); // example password Contacts.setUrl("jdbc:odbc:ContactDB"); // example DSN Contacts.setCommand("SELECT name, telephone from Contacts"); Contacts.execute(); %> </jsp:useBean>http://www.javaworld.com/javaworld/jw-02-2001/jw-0202-cachedrow.html
Password Database user password
URL Database JDBC URL such as jdbc:odbc:mydsn
Command SQL query statement Because it is a JavaBean, you can simply use the default constructor when creating a new instance of the CachedRowSet object: CachedRowSet crs = new CachedRowSet();
<jsp:useBean id="Contacts"
class="sun.jdbc.rowset.CachedRowSet"
scope="session">
<%
// load database driver
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
// initialize our CachedRowSet bean
Contacts.setUsername("dbuser"); // example userid
Contacts.setPassword("dbpassword"); // example password
Contacts.setUrl("jdbc:odbc:ContactDB"); // example DSN
Contacts.setCommand("SELECT name, telephone from Contacts");
Contacts.execute();
%>
</jsp:useBean>http://www.javaworld.com/javaworld/jw-02-2001/jw-0202-cachedrow.html