View records from the Access/SQL table using Swing JTable

Home  »  Java  »  Advance Java  »  Java Database Connectivity  »  View records-GUI


This example shows records from the Access table 'SchoolClasses' on the hard disk, using classes of java.sql and java.awt and more packages with Grapchical User Interface. This program simply use UI component of java swing like JLabel, JButton, JMenu and JTable, after view records from database in java table you can simple print the records using print() method of java.

  •  A JDBC-ODBC bridge driver is loaded
  •  A Connection to the database is made, using getConnection method()
  •  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:

Database NameSchoolDemo.mdb
Table NameSchoolClasses
Primary KeyAdmission_No




The Output of View table is as shown below:





Diagram 22.25



After running ViewRecords.class file you will see above screen just simply click on 'View Records' Button this will show the next screen as shown in diagram 22.27 in JTable.



Diagram 22.26 of ViewRecords.class in JTable



You can use print command too in java using print() method as shown in below diagram 22.28.


Diagram 22.27 using printer in JTable



JDBC - Working With User Interfaces - Using Swing Compoents

Inserts records into the Access/SQL table using Swing Components
View records from the Access table/SQL using Swing JTable
Updates records into the Access/SQL table using Swing Components
Deletes records from the Access/SQL table using Swing Components






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