Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to i discrete arraylist elements
    primarykey
    data
    text
    <p>I have the following class which is use for catch up ALL the row records from ALL MySQL tables for a specific schema:</p> <pre><code>public 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()) { db1TableName = resTables1.getString("TABLE_NAME"); resTablesStr1 = statement1.executeQuery("SELECT * FROM "+db1TableName+";"); resColumns1 = resTablesStr1.getMetaData(); db1TotalColNum = resColumns1.getColumnCount(); db1FirstColName = resColumns1.getColumnName(1); //Object k = resTablesStr1.getObject(db1FirstColName); //System.out.println("| "+k.toString()+" |"); for (int i=1; i&lt;=db1TotalColNum; i++) { db1CurColNum = i; db1ColName = resColumns1.getColumnName(i); db1ColDataType = resColumns1.getColumnTypeName(i); resTablesData1 = statement1.executeQuery("SELECT "+db1ColName+" FROM "+db1TableName+" GROUP BY "+db1FirstColName+";"); resTablesData1.last(); db1TotalRowNum = resTablesData1.getRow(); resTablesData1.beforeFirst(); db1CurRowNum = 0; while (resTablesData1.next()) { db1CurRowNum++; ObjRowValues = resTablesData1.getObject(db1ColName); rows.add(new CellValue(db1TableName,db1ColName,db1CurColNum,db1CurRowNum,db1ColDataType,ObjRowValues.toString())); } //cells.add(row); } } for (CellValue r : rows) { System.out.println("TABLE: " + r.getTable() +" "+"COLUMN: " + r.getColumn() +" "+"COLUMN_ID: " + r.getcolID() +" "+"ROWD_ID: " + r.getrowID() +" "+"COLUMN_TYPE: " + r.getcellType()+" "+"ROW_VALUE: " + r.getcellValue()); } } catch (SQLException e) { System.err.println("Connection Failed! Check output console " + e.getMessage()); System.exit(0); } } </code></pre> <p>CellValue class is the following:</p> <pre><code>public class CellValue { String tab; String col; int colID; int rowID; String cellType; String cellValue; public CellValue(String tab, String col, int colID, int rowID, String cellType, String cellValue) { this.tab = tab; this.col = col; this.colID = colID; this.rowID = rowID; this.cellType = cellType; this.cellValue = cellValue; } public String getTable() { return this.tab; } public String getColumn() { return this.col; } public int getcolID() { return this.colID; } public int getrowID() { return this.rowID; } public String getcellType() { return this.cellType; } public String getcellValue() { return this.cellValue; } } </code></pre> <p>When I execute the <code>GetAllDataDB1()</code> through <code>public static void main class</code>, the result I get is the list which contains ALL the row data from ALL tables exist in the specific schema. My purpose is to compare ALL the rows records from every table (one by one) with all the records from every table belongs to another schema. How can I specify all the records from my <code>arraylist</code> which refers to every table? Now as you realize I have ALL the records from ALL tables in one <code>arraylist</code> and I want to separate them so my search become more easy.</p> <p>Dear Robin Green, I already have the "four levels" as you advice at your answer. Although the comparison I want to succeed is more complicate. Actually I want to compare every row of column X of the first database with every row of column Z of the second database where column X and column Z have the same data type. There is no meaning to compare rows of an int type column with all rows a varchar column. Further more I want to determine some more than a simple equals of rows. I want to decide when a row describes the same object with another row belongs to a different database's table and probably both rows are not totally equals. For example I have a row with values: "Robin"(name), "220000"(id), "99800000"(phone) and a row with values: "Robyn"(name), "220000"(id), "97677999"(phone). We are talking about the same person even the name and the phone are different. After my clarifications please give me your thoughts and advices.</p> <p>Thank in advance.</p>
    singulars
    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.
 

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