I am a new Java programmer. I am confused with using an array with the getTable method. This code only work if I either leave the array empty like --String [] types={}; or with a {"TABLE"}; inside... I tried accessing the array besides the RS and there is no table names stored in it.... Why do we even use this Array and pass its name in getTable method bcz to see table names we print the rs .... I dont understand the purpose of this array with {"TABLE"} written inside and also what is this String[] types = {"TABLE", "VIEW"}; for... why wont this work if I wrote like String [] types = {"hey", "you"};
public void getDatabaseMetaData(){
try {
DatabaseMetaData md = conn.getMetaData();
String[] types = {"TABLE"};
//OR using String[] types = {"TABLE", "VIEW"};
Result-set rs = md.get-tables(null, null, "%", types);
while (rs.next()) {
System.out.println(rs.getString("TABLE_NAME"));
}
}
catch (SQLException e) {
e.printStackTrace();
}
}