Java jdbc元数据getTables只列出表列表
当我使用下面的语法时,我试图从数据库中列出表Java jdbc元数据getTables只列出表列表,java,jdbc,metadata,Java,Jdbc,Metadata,当我使用下面的语法时,我试图从数据库中列出表 ResultSet rs = md.getTables(null, null, "%" ,null); 这将返回数据库中的所有表、视图、索引和系统表 但是我只需要公共模式中的表列表,所以我给出了下面的语法 ResultSet rs = md.getTables(null, "public", "%" ,"TABLE"); 这向我显示了以下错误 required: String,String,String,String[] found: <n
ResultSet rs = md.getTables(null, null, "%" ,null);
这将返回数据库中的所有表、视图、索引和系统表
但是我只需要公共模式中的表列表,所以我给出了下面的语法
ResultSet rs = md.getTables(null, "public", "%" ,"TABLE");
这向我显示了以下错误
required: String,String,String,String[]
found: <null>,String,String,String
reason: actual argument String cannot be converted to String[] by method invocation conversion
必需:字符串,字符串,字符串,字符串[]
找到:,字符串,字符串,字符串
原因:无法通过方法调用转换将实际参数字符串转换为字符串[]
只需要从公共模式中单独列出表
plz语法帮助建议最后一个参数应该是字符串数组
public ResultSet getTables(String catalog,
String schemaPattern,
String tableNamePattern,
String[] types)
throws SQLException
getTables()
的签名需要一个数组作为第四个参数。试一试
ResultSet rs = md.getTables(null, "public", "%" ,new String[] {"TABLE"} );
传递一个数组,其中一个值“TABLE”作为最后一个参数。见Brian Agnew的答案