Home arrow Java arrow Finding and Traversing Rows using NetBeans IDE

Finding and Traversing Rows using NetBeans IDE

This series introduces you to a step-by-step process to develop Java (or JFC) based applications with Microsoft SQL Server as the database, using NetBeans IDE. In this article, I shall introduce you to finding and traversing rows using Java.

Author Info:
By: Jagadish Chaterjee
Rating: 5 stars5 stars5 stars5 stars5 stars / 3
June 21, 2006
  1. · Finding and Traversing Rows using NetBeans IDE
  2. · The code generated
  3. · The heart of the application
  4. · Explaining the code

print this article

Finding and Traversing Rows using NetBeans IDE
(Page 1 of 4 )

A downloadable file for this article is available here.

I already introduced you to NetBeans IDE in my earlier article "Developing Java Applications using NetBeans."  Even though that article is fairly introductory, the next two articles focus on the basics of JFC.  You can find the next two articles here and here.

If you are new to NetBeans IDE, I strongly suggest you go through the existing articles first, before proceeding with this one.  If you are new to developing Microsoft SQL Server based Java applications, I request that you go through another article of mine here

How to search for a database row in Java using NetBeans IDE: creating an application

In my previous article, I gave a few examples of working with DML and DDL statements in Java. You can consider this section to be an extension to that article. In this section, we will look into searching and displaying data from tables using NetBeans IDE.

We shall develop a small application with four labels, four text boxes and a button.  When the button is hit, it tries to find a row based on the "empno" provided by the user. The "Northwind" database, by default, doesn't have any "emp" table.  I just created it for simplicity; you can find the structure together with the rows of that table in my previous article.

Currently, I named the project "SampleJavaApplication1" and the form (or JFrame) "DBSample05" in the package "MyDBPack."

When the form (or JFrame) is created with "DBSample05," the code behind it (only the constructor) would look something like the following:

public class DBSample05 extends javax.swing.JFrame {   

    /** Creates new form DBSample05 */
    public DBSample05() {

Make changes to the above code fragment in such a way that it looks similar to the following:

public class DBSample05 extends javax.swing.JFrame {   

    /** Creates new form DBSample05 */
    public DBSample05() {

In the above code, I explicitly defined the initial size of the frame. Before dropping all controls on the form, set the layout to "null layout" (fig 01) to ease your development for this article.  When you complete your form design, it should look something like Fig 1, and the "inspector" view should look something like Fig 2. 


Fig 1

Fig 2

For the convenience of writing understandable code, I named those controls as follows:

jLabel1, jLabel2, jLabel3, jLabel4 (default names)

I also gave a value to the Frame property "title" (using the property window), which is simply "PreparedStatement using Java: Demo."

You need to import certain packages, as shown below:

import java.sql.*;

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