Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Sorry, but your code is wrong in so many ways. So let me first get this right as to what you are trying to do. I believe you want to basically dump the complete database, i.e. print data from all the rows from all the tables. Is that right? Assuming that's what you want to do, here's how it will work (I didn't test the program, so there might be compilation errors):</p> <pre><code>public static void getAllDataDB1() // Catching all the data from "bank1" database { try { MetaData1 = connection1.getMetaData(); catalogs1 = MetaData1.getCatalogs(); String[] types = {"TABLE"}; resTables1 = MetaData1.getTables(null,null,"%",types); while (resTables1.next()) // Loop for all the tables { db1TableName = resTables1.getString("TABLE_NAME"); System.out.println("|=====================================================|"); System.out.println("| CATCHING " +dbName1+"."+db1TableName+ " DATA |"); System.out.println("|=====================================================|"); System.out.println("|=====================================================|"); System.out.println("| THE QUERY IS IN PROGRESS. PLEASE WAIT... |"); System.out.println("|=====================================================|"); resTablesStr1 = statement1.executeQuery("SELECT * FROM "+db1TableName+";"); resColumns1 = resTablesStr1.getMetaData(); db1ColNum = resColumns1.getColumnCount(); // db1FirstColName = resColumns1.getColumnName(1); // Dont need this while (resTablesStr1.next ()) // Loop for each row of data { System.out.println("\n ------ Row -----\n"); for (int i=1; i&lt;=db1ColNum; i++) // Loop for each column in the row { db1ColName = resColumns1.getColumnName(i); System.out.println("| COLUMN: " +db1ColName+ " |"); System.out.println("\n"); String rowData = resTablesData1.getString(db1ColName); System.out.println(); System.out.println("|-----------------------------------------------------|"); System.out.print("| "+rowData+" |"+"\t"); System.out.println("|-----------------------------------------------------|"); } } } } catch (SQLException e) { System.err.println("Connection Failed! Check output console " + e.getMessage()); System.exit(0); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload