Reputation: 10163
i am trying to list tables from a database, when i use the below syntax
ResultSet rs = md.getTables(null, null, "%" ,null);
this returns me all the tables, views, index, system_tables from the database.
but i need only list of tables from the public schema so i have given the below syntax,
ResultSet rs = md.getTables(null, "public", "%" ,"TABLE");
which shows me the following error
required: String,String,String,String[]
found: <null>,String,String,String
reason: actual argument String cannot be converted to String[] by method invocation conversion
just need to list the tables alone from public schema.
plz help with the syntax
Upvotes: 2
Views: 8331
Reputation: 86754
The signature for getTables()
expects an array as the fourth argument. Try
ResultSet rs = md.getTables(null, "public", "%" ,new String[] {"TABLE"} );
Upvotes: 6
Reputation: 272217
The Javadoc suggests your last parameter should be an array of strings.
public ResultSet getTables(String catalog,
String schemaPattern,
String tableNamePattern,
String[] types)
throws SQLException
Upvotes: 6