Transcribed TextTranscribed Text

(Display table contents) Write a program that displays the content for a giventable. As shown below, you enter a table and click the Show Contentsbutton to display the table contents in the text area. The column names and table names must be read from Metadata. Choose Table to Display x Table Name enrollment Show Contents ssn courseld dateRegistered grade 444111110 11111 2009-08-12 A 444111110 11112 2009-08-12 B 444111110 11113 2009-08-12 C 444111111 11111 2009-08-12 D 444111111 11112 2009-08-12 F 11112 2000 01 19 A

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

import java.awt.Font;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.*;

public class GUI extends JFrame {

    private Connection connection;

    * Creates new form GUI
    public GUI() {
       jTextAreaOutput.setFont(new Font("Monospaced", Font.PLAIN, 12));
       try {
       } catch (SQLException e) {
            JOptionPane.showMessageDialog(null, e.getMessage());

    private void connecting() throws SQLException {
       connection = DriverManager.getConnection("jdbc:sqlserver://;"
                + "databaseName= CUNY_DB; integratedSecurity=false;",
                "cst3613", "password1");
       // Create a statement
       Statement statement = connection.createStatement();

       // get name of all table in the database
       ResultSet resultSet = statement.executeQuery("select table_name from CUNY_DB.INFORMATION_SCHEMA.TABLES where TABLE_TYPE = 'BASE TABLE'");
       while ( {

    * create the GUI
    private void initComponents() {

       jScrollPane1 = new JScrollPane();
       jTextAreaOutput = new JTextArea();
       jLabel1 = new JLabel();
       jComboBoxTable = new JComboBox<>();
       jButtonShow = new JButton();

       setTitle("Choose Table to Display");


       jLabel1.setText("Table Name");

       jButtonShow.setText("Show Contents");
       jButtonShow.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {

       GroupLayout layout = new GroupLayout(getContentPane());
                        .addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                               .addContainerGap(176, Short.MAX_VALUE)
                               .addComponent(jComboBoxTable, GroupLayout.PREFERRED_SIZE, 99, GroupLayout.PREFERRED_SIZE)
                               .addGap(152, 152, 152))
                                        .addComponent(jComboBoxTable, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                               .addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 249, Short.MAX_VALUE))


By purchasing this solution you'll be able to access the following files:

for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats