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

Create a Swing application that looks and behaves like the example located at th

ID: 3530447 • Letter: C

Question

Create a Swing application that looks and behaves like the example located at the top of this assignment. Start with your code from week one and implement the use of the Oracle database in place of the array used in week one.


The functionality you are looking for is the following:

Modify your CLASSPATH environment variable to include both the Oracle thin drivers .jar file and the current working directory.


Load the Oracle Thin Drivers Create a connection to the Oracle database. Execute a query of the database to retrieve a populated ResultSet.


Then with the populated ResultSet: The Previous button will iterate through the ResultSet moving to the previous element each time the button is clicked and will then update the GUI with the newly selected data. If the Previous button is selected while the ResultSet is positioned at the first element, your program should then move the last element and update the display with the newly selected data. The Next button will iterate through the ResultSet moving to the next element each time the button is clicked and will then update the GUI with the newly selected data. If the Next button is selected while the ResultSet is positioned at the last element, your program should then move the first element and update the display with the newly selected data. When the Reset button is selected you should move to the first element in the ResultSet and update the display.


Week 1 Code that needs to be edited to pull from database.


//main program to given data

import javax.swing.*;

import java.awt.*;

class Weekone extends JFrame

private JTextField textFieldCity = new JTextField();

private JTextField textFieldState = new JTextField();

private JTextField textFieldZip = new JTextField();

DataClass[] DataClassArray = {

new DataClass("James", "William", "101 Here", "Ok", "123234"),

new DataClass("Martin", "Edan", "102 There", "Androed", "123235"),

new DataClass("Ebenzer", "Rachel", "103 No Where", "OK", "123236") };

int arrayPointer = 0;

public Weekone(String title)

}

{

public void actionPerformed(java.awt.event.ActionEvent evt)

{

}

a2.setSize(400, 350);

a2.setVisible(true);

}

}

class DataClass

}

}

}

}


Database Details:


CREATE TABLE address(
id NUMBER (4) CONSTRAINT pk_address PRIMARY KEY,
LASTNAME varchar2(40),
FIRSTNAME varchar2(40),
STREET varchar2(40),
CITY varchar2(40),
STATE varchar2(40),
ZIP varchar2(40)
);

INSERT INTO address VALUES(1,'Smith','Tom','2919 Redwing Circle','Bellevue','NE','68123');

INSERT INTO address VALUES(2,'Actor','Marty','1000 Galvin Road South','Bellevue','NE','68005');

INSERT INTO address VALUES(3,'Aimes','Beverly','1 Park Place','Redmond','Washington','90922');

COMMIT;

Explanation / Answer

import java.sql.*;

import oracle.jdbc.OracleResultSetMetaData;

// assumes you have installed the oracle thin drivers - see link on main page

public class OracledBweekone{

public static void main(String args[ ])

{

   try{
      DriverManager.registerDriver (new oracle.jdbc.OracleDriver());

      //Connect to the URL

     // Step through the records

     System.out.println("Received Results:");

     int i = rs.getMetaData().getColumnCount( );

     while(rs.next( ) )

     {

       for(int x = 1; x <= i; ++x)

      {

         System.out.println(rs.getString(x));

       }

       System.out.println("");

     }

       stmt.close( );

       con.close();

    }

    catch (java.lang.Exception ex)

     {

      ex.printStackTrace();

     }

}

}

//main program to given data

import javax.swing.*;

import java.awt.*;

class Weekone extends JFrame

    private JTextField textFieldCity = new JTextField();

    private JTextField textFieldState = new JTextField();

    private JTextField textFieldZip = new JTextField();

    DataClass[] DataClassArray = {

         new DataClass("James", "William", "101 Here", "Ok", "123234"),

         new DataClass("Martin", "Edan", "102 There", "Androed", "123235"),

         new DataClass("Ebenzer", "Rachel", "103 No Where", "OK", "123236") };

    int arrayPointer = 0;

    public Weekone(String title)

            }

        {

            public void actionPerformed(java.awt.event.ActionEvent evt)

            {

        }

        a2.setSize(400, 350);

        a2.setVisible(true);

    }

}

class DataClass

    }

    }

    }

}