// Fig. 18.24: ParmGet.java // This program displays the contents of the Authors table // in the Books database. import java.sql.*; import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.util.*; import java.io.*; public class ConclusionGet extends JFrame { public String [][] concs; private Connection connection; private JTable table; public int noRows; public ConclusionGet() { // The URL specifying the Books database to which // this program connects using JDBC to connect to a // Microsoft ODBC database. String url = "jdbc:odbc:xshell"; String username = ""; String password = ""; // Load the driver to allow connection to the database try { Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" ); connection = DriverManager.getConnection( url, username, password ); } catch ( ClassNotFoundException cnfex ) { System.err.println( "Failed to load JDBC/ODBC driver." ); cnfex.printStackTrace(); System.exit( 1 ); // terminate program } catch ( SQLException sqlex ) { System.err.println( "Unable to connect" ); sqlex.printStackTrace(); } getTable(); shutDown(); } private void getTable() { Statement statement; ResultSet resultSet; try { String query= "SELECT * FROM ConclusionText"; statement = connection.createStatement(); resultSet = statement.executeQuery( query ); displayResultSet( resultSet ); statement.close(); } catch ( SQLException sqlex ) { System.err.println( "Error with Parameters"); sqlex.printStackTrace(); } } private void displayResultSet( ResultSet rs ) throws SQLException { // position to first record boolean moreRecords = rs.next(); // If there are no records, display a message if ( ! moreRecords ) { JOptionPane.showMessageDialog( this, "ResultSet contained no records" ); return; } Vector columnHeads = new Vector(); Vector rows = new Vector(); try { // get column heads ResultSetMetaData rsmd = rs.getMetaData(); for ( int i = 1; i <= rsmd.getColumnCount(); ++i ){ columnHeads.addElement( rsmd.getColumnName( i ) ); } // get row data int b=0; String [][] p2=new String [10000][2];; do { //int b=0; int c=0; for ( int i = 1; i<= rsmd.getColumnCount(); ++i ){ if(rsmd.getColumnTypeName(i).equals("VARCHAR")){ p2[b][i-1]= rs.getString(i); if(i==2){b++;} } else{ if(rsmd.getColumnTypeName(i).equals("INTEGER")){ long l=rs.getLong(i); String st=""+l; p2[b][i-1]= st; if(i==2){b++;} } else{ p2[b][i-1]= rs.getString(i); if(i==2){b++;} } } } } while ( rs.next() ); concs=new String [b][2]; int b2=0; while(b2