Home arrow Java arrow Exploring JDBC and XML

Exploring JDBC and XML

For those who want to delve deeply into Java, this article continues our exploration of Java Database Connectivity (JDBC), examines JDBC drivers, and introduces you to using XML. The second of three parts, it is excerpted from chapter 20 of the book Sams Teach Yourself Java 2 in 21 Days, 4th Edition, written by Rogers Cadenhead and Laura Lemay (Sams; ISBN: 0672326280).

Author Info:
By: Sams Publishing
Rating: 3 stars3 stars3 stars3 stars3 stars / 5
June 15, 2006
  1. · Exploring JDBC and XML
  2. · JDBC Drivers
  3. · Using XML
  4. · Processing XML with Java and XOM

print this article

Exploring JDBC and XML
(Page 1 of 4 )

Moving Through Resultsets

The default behavior of resultsets permits one trip through the set using its next() method to retrieve each record.

By changing how statements and prepared statements are created, you can produce resultsets that support these additional methods:

  • afterLast()óMoves to a place immediately after the last record in the set

  • beforeFirst()óMoves to a place immediately before the first record in the set

  • first()óMoves to the first record in the set

  • last()óMoves to the last record in the set

  • previous()óMoves to the previous record in the set

These actions are possible when the resultset's policies have been specified as arguments to a database connection's createStatement() and prepareStatement() methods.

Normally, createStatement() takes no arguments, as in this example:

Connection payday = DriverManager.getConnection(
"jdbc:odbc:Payroll", "Doc", "1rover1");
Statement lookSee = payday.CreateStatement();

For a more flexible resultset, call createStatement() with three integer arguments that set up how it can be used. Here's a rewrite of the preceding statement:

Statement lookSee = payday.CreateStatement(

The same three arguments can be used in the prepareStatement(String, int, int, int) method after the text of the statement.

The ResultSet class includes other class variables that offer more options in how sets can be read and modified.

blog comments powered by Disqus

- Java Too Insecure, Says Microsoft Researcher
- Google Beats Oracle in Java Ruling
- Deploying Multiple Java Applets as One
- Deploying Java Applets
- Understanding Deployment Frameworks
- Database Programming in Java Using JDBC
- Extension Interfaces and SAX
- Entities, Handlers and SAX
- Advanced SAX
- Conversions and Java Print Streams
- Formatters and Java Print Streams
- Java Print Streams
- Wildcards, Arrays, and Generics in Java
- Wildcards and Generic Methods in Java
- Finishing the Project: Java Web Development ...

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials