This tutorial will show you how to create a Java desktop application to access and update the database. This tutorial leverages the following technologies supported by NetBeans IDE 6.0:
Java Persistence API (JPA) to help you use Java code to interface with a database
Beans binding technology (JSR 295) provides a way for different JavaBeans controls to synchronize property values with each other. For example, you can use the Beans binding technique to keep the values of each cell in a JTable visual control synchronized with the values of each field in the entity class. (Here, the entity class represents the data table)
The Swing application framework (JSR 296) provides some very useful artifacts for building desktop applications quickly.
We will create a database CRUD (add, delete, change, check) application, using a custom control to visualize the data (car design preview).
Most of this tutorial is based on screenshots in the development process. Some parts of the user interface may change in the presentation process, so you may notice some differences between the tutorials and the demo program. You can now browse the demo program (estimated about 9 minutes) or download the demo program (Http://www.netbeans.org/files/documents/4/1714/netbeans_6_gui_builder.zip).
To learn this tutorial, you need to install the following software on your computer:
NetBeans IDE 6.0.
Java Standard Development Kit (JDK) version 5.0 or 6.0
Java DB database server (Java DB already included in JDK 6)
SQL description of the database, see Http://usersguide.netbeans.org/files/documents/40/1423/car.sql.
Carpreview Project's engineering package, see Http://usersguide.netbeans.org/files/documents/40/1433/CarPreview.zip
Building a Database
Before you start creating a CRUD (add, delete, change, check) desktop application in the IDE, you should already have your IDE link on the database used by the application. Complete this link the Advanced settings allow you to use the advanced features of the IDE to help you automatically bind the database to your application.
In this tutorial, we provide a tutorial on using the Java DB Database because it provides a convenient interface in the IDE to start and stop the Java DB database. However, you can also select a different database if you are not in trouble.
First check to see if you have registered Java DB in the IDE. In general, Java DB is automatically registered in the IDE, such as when you register the Sun Java System application Server in the IDE or when you run a program on JDK 6.
Make sure that Java DB is already registered in the IDE:
Open the Tools menu and click on the submenu of the Java DB Database.
If the Settings menu is the only one that is not marked, you need to manually start the registration of Java DB in the IDE.
To manually register Java DB in the IDE:
Select Tools > Java DB Database > Settings.
Enter the installation path for the database server in the JAVADB installation path
In the database Location attribute, select a folder to store the database files.
Click OK.