java.sql.ResultSetMetaData is an interface of JDBC API and the implementation has to be given by JDBC vendors. This interface is mainly used to identify the meta data information on the ResulstSet i.e.; we get the number of columns and their data type a etc. Below is an example program which will return the column names and columns types of a table PRODUCT.

import java.sql.*;

* A demo class to explain ResultSetMetaData
* @author Santhosh Reddy Mandadi
* @since 25-Jun-2012
* @version 1.0

public class ResultSetMetaDataDemo
public static void main(String args[]) throws Exception
String driverClass, jdbcURL, userName, password;
driverClass = "oracle.jdbc.driver.OracleDriver";
jdbcURL = "jdbc:oracle:@localhost:1521:xe";
userName = "scott";
password = "tiger";
Connection connection = DriverManager.getConnection(jdbcURL, userName, password);
Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery("SELECT * FROM PRODUCT");
ResultSetMetaData metaData = resultSet.getMetaData();
System.out.println("Number of columns: "+metaData.getColumnCount());
for(int i=1;i< metaData.getColumnCount();i++)