Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Problem Statement: Develop a simple GUI based databasedriven application for a B

ID: 3610750 • Letter: P

Question

Problem Statement:
Develop a simple GUI based databasedriven application for a Bank system.
Requirements:-
   * Building asimple GUI bases application for a Bank system    * Creating a MSAccess database    * Connecting to database    * Querying thedatabase using SQL statement    * Displayingresult of query from database to GUI
Detailed Description:-
   * Use MS Accessto create a database named “Bank” and add a table to itnamed “Account”.    * The Accounttable of Bank database must have following fields.    1.Account Number    2.Account Holder Name    3.Account Type    4.Account Balance
   * Enter at least15 records in the Account table.    * Create a SystemDSN named “bankDSN”. Use this DSN to connect todatabase.    * Write a programwhich will connect to this database and query all the records fromthe “Account” table using SQL statement and displaythem on GUI application.    * You can useGrid Layout to display the records from database to GUIapplication.    * You must useResultSetMetaData to display exact name of columns of databasetable on the top of GUI application. Marks will be deducted in caseof not using ResultSetMetaData.    * You should useJlabel in every cell of the grid layout to display a field fromdatabase table
Develop a simple GUI based databasedriven application for a Bank system.
Requirements:-
   * Building asimple GUI bases application for a Bank system    * Creating a MSAccess database    * Connecting to database    * Querying thedatabase using SQL statement    * Displayingresult of query from database to GUI
Detailed Description:-
   * Use MS Accessto create a database named “Bank” and add a table to itnamed “Account”.    * The Accounttable of Bank database must have following fields.    1.Account Number    2.Account Holder Name    3.Account Type    4.Account Balance
   * Enter at least15 records in the Account table.    * Create a SystemDSN named “bankDSN”. Use this DSN to connect todatabase.    * Write a programwhich will connect to this database and query all the records fromthe “Account” table using SQL statement and displaythem on GUI application.    * You can useGrid Layout to display the records from database to GUIapplication.    * You must useResultSetMetaData to display exact name of columns of databasetable on the top of GUI application. Marks will be deducted in caseof not using ResultSetMetaData.    * You should useJlabel in every cell of the grid layout to display a field fromdatabase table

Explanation / Answer

Create MS Access database with same given table and fields name andcreate DSN with the name of "bankDSN" import java.awt.*; import javax.swing.*; import java.sql.*; public class BankAccount {     public BankAccount() {         JFrame mainFrame = newJFrame("Bank Account");         Container c =mainFrame.getContentPane();         try {            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");                         String url= "jdbc:odbc:bankDSN";                         Connectionconnection = DriverManager.getConnection(url);                         Statementstatement =connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);             // SelectAll records from accounts table             StringsqlQuery = "SELECT * FROM Account";             // executequery and fetch records             ResultSetresultSet = statement.executeQuery(sqlQuery);             // toadjust more columns and rows dynamically... its optional forstudents, they can use hardcoded values            ResultSetMetaData resultSetMetaData = resultSet.getMetaData();             // movingto end            resultSet.last();             // gettingtotal rows in result set             int rows =resultSet.getRow();                       // one rowfor header            rows++;             // gettingcolumns count             intcolumns = resultSetMetaData.getColumnCount();                        c.setLayout(new GridLayout(rows, columns));             //database fields name             c.add(newJLabel("AccountNumber"));             c.add(newJLabel("AccountHolder"));             c.add(newJLabel("AccountType"));             c.add(newJLabel("AccountBalance"));                        resultSet.beforeFirst();                         while(resultSet.next()) {                c.add(newJLabel(resultSet.getString("AccountNumber")));                c.add(newJLabel(resultSet.getString("AccountHolderName")));                c.add(newJLabel(resultSet.getString("AccountType")));                c.add(newJLabel(resultSet.getString("AccountBalance")));             }             //closethe connection            connection.close();                } catch(Exception sqlEx){            System.out.println(sqlEx);         }        mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);         mainFrame.setSize(800,350);        mainFrame.setVisible(true);     }         public static void main(String args[]){         BankAccount bankAccount = newBankAccount();     }    }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote