What Is a ResultSetMetaData Object? JDBC

JDBC’s result set metadata, expressed as the java.sql.ResultSetMetaData interface, is a set of structured data that can be used to get information about the types and properties of the columns in a ResultSet object.

It is very easy to create a ResultSetMetaData object. The following code fragment creates a ResultSet object rs, and then uses rs to create a ResultSetMetaData object rsMetadata, and finally uses rsMetadata to find out how many columns rs has:

If you do not know exactly the table structure (the schema) of the ResultSet, you can obtain it via a ResultSetMetaData object. The ResultSetMetaData interface answers the following questions:

  • How many columns are in a result set (ResultSet object)?
  • What is the name of a given column?
  • What is the name of a table for a given column?
  • Are the column names case sensitive?
  • What is the data type of a specific column?
  • What is the maximum character size of a column?
  • Can you search on a given column?
  • Is a given column readable/writable?

Face Book Twitter Google Plus Instagram Youtube Linkedin Myspace Pinterest Soundcloud Wikipedia

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

JDBC Topics