Home | » | Java | » | Advance Java | » | Java Database Connectivity | » | Delete records-GUI |
---|
This example delete record from the Access table 'SchoolClasses' on the hard disk, using classes of java.sql and java.awt and more packages with Grapchical User Interface.
- A JDBC-ODBC bridge driver is loaded
- A Connection to the database is made, using getConnection method()
- Using the Connection object, SQL's 'Delete' statement is sent to the database
- A message is printed on the command line indicating the command was successful
- Minimal exception handling is done
To build these concepts and skill, a 'SchoolClasses' table will be used as a working model. This table will be created in an Access database i.e. the SchoolDemo.mdb database will hold a 'SchoolClasses' table. The structure of the table will be as described below:
|
The Following block of code creates the UI described using Java Swing Components.
The Output of DeleteRecords table is as shown below:
|
|
Diagram 22.34 output of DeleteRecords.class |
After running DeleteRecords.class file you will see above screen just enter Reg.No/AdmissionNo into Reg.No textbox and click on 'Search' Button this will show the next screen as shown in diagram 22.35, if reg.no is exists then it will show records otherwise it will give error message that. "Registration No. ...... is Not Exist!!!"
|
Diagram 22.35 entering Reg.No into Reg.No JTextBox |
If Reg.No 603 is Exist then it will shown below diagram 22.28. You can use Keyboard short cut to search records like 'Alt + S'. Same for Delete Record 'Alt + D'.
|
Diagram 22.36 Reg.No is Exist |
|
Diagram 22.37 Warring Message "Do You Really Want To Delete The Record ? 603" |
|
Diagram 22.38 Record Deleted Successfully |
JDBC - Working With User Interfaces - Using Swing Compoents
JDBC - Programming:
![]() |
View records from the Access/SQL table. |
![]() |
Inserts records into the Access/SQL table. |
![]() |
Updates records into the Access/SQL table. |
![]() |
Deletes records from the Access/SQL table. |
![]() |
Drops the Access/SQL table. |
No comments:
Post a Comment