在运行执行一些sql语句后,我从结果集获得了一些元数据。我想从元数据中获得表名。我正在使用
Metadata.getTableName(1);
但是它没有返回任何东西;这是什么意思?还请注意,我能够成功地从元数据中获取列名,而不是表名。
你必须使用DatabaseMetaData md = connection.getMetaData();
From javadocwhich retrieves a DatabaseMetaData object that contains metadata about the database to which this Connection object represents a connection. The metadata includes information about the database's tables, its supported SQL grammar, its stored procedures, the capabilities of this connection, and so on.