Home arrow Java arrow Page 5 - Developing SQL Server based Java Apps using NetBeans IDE
JAVA

Developing SQL Server based Java Apps using NetBeans IDE


This article introduces you to developing Java (or JFC) based applications with Microsoft SQL Server as the database, using NetBeans IDE. In this first article in a series, I will show you how to establish a connection from your Java programs to a Microsoft SQL Server database using JDBC.

Author Info:
By: Jagadish Chaterjee
Rating: 4 stars4 stars4 stars4 stars4 stars / 27
May 24, 2006
TABLE OF CONTENTS:
  1. · Developing SQL Server based Java Apps using NetBeans IDE
  2. · What do we need to connect to Microsoft SQL Server from Java (or JDBC)?
  3. · How to configure CLASSPATH to connect to Microsoft SQL Server database
  4. · How to establish a Microsoft SQL Server database connection using JDBC
  5. · Creating a Microsoft SQL Server database connection using NetBeans IDE: Form Design
  6. · Creating a Microsoft SQL Server database connection using NetBeans IDE: the nucleus

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
Developing SQL Server based Java Apps using NetBeans IDE - Creating a Microsoft SQL Server database connection using NetBeans IDE: Form Design
(Page 5 of 6 )

In this section, instead of simply connecting to Microsoft SQL Server, I shall go a bit further to give us the number of rows available in a table. This would be much more practical.

We shall develop a small application with a button, ScrollPane and TextArea.  When the button is hit, it needs to give out the number of rows available. I named the project “SampleJavaApplication1” and the form (or JFrame) as “DBSample01” in the package “MyDBPack.”

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

  public class DBSample01 extends javax.swing.JFrame { 

    /** Creates new form DBSample01 */
    public DBSample01() {
        initComponents();
    }

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

  public class DBSample01 extends javax.swing.JFrame {   

    /** Creates new form DBSample01 */
    public DBSample01() {
        initComponents();
        this.setSize(300,200);
    }

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 02) to ease our development for this article.  When you complete your form design, it should look something like fig 2, and the “inspector” view should look something like fig 2-1.


Figure 02. "null layout".


Figure 02-1.
"inspector" view.

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

tbtnBold
tbtnItalic
txtMsg

I also gave a value to the Frame property “title” (using the property window), namely “ToggleButtons: a Demo.”


blog comments powered by Disqus
JAVA ARTICLES

- 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 ...
- Generics and Limitations in Java
- Getting Started with Java Web Development in...

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



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