ResultSetMetaData is a Java class, which provides information about the ResultSet and implements the java.sql.ResultSetMetaData interface. The column name, column type, and so forth are provided by the ResultSetMetaData object. Database vendors provide different classes for implementing the ResultSetMetaData interface. To learn about a given result set from a database (expressed as a ResultSet object), you must obtain (or create) a ResultSetMetaData object. Once a client program has obtained a valid ResultSet, the following code gets a metadata object:ResultSet rs = null;
The ResultSetMetaData interface has over two dozen methods. Using ResultSetMetaData, an application can discover the number of columns returned, as well as an individual column’s suggested display size, column names, column types, and so on. Note that a given JDBC driver may not provide information for all of the methods, so you need to check returned objects for nulls or empty strings.
A ResultSet object provides a table of data representing a database result set, which is usually generated by executing a statement that queries the database. The ResultSet object is one of the most important objects in the JDBC API. ResultSet is basically an abstraction of a table of general width and unknown length. Most of the methods and queries return result data as a ResultSet. A ResultSet contains any number of named columns that you can ask for by name. It also consists of one or more rows, which you can move through sequentially from top to bottom, one at a time. Before you can use a ResultSet, you need to inspect the number of columns it contains. This information is stored in the ResultSetMetaData object.//get the number of columns from the "ResultSet metadata"
When you obtain a ResultSet, it points just before the first row. To iterate all of the rows, you can use the next() method to obtain each additional row, and the method returns false when no more rows remain. Since fetching data from a database can result in errors, you must always enclose your result set manipulations in a try/catch block.
Here’s an example:import java.sql.*;
JDBC Related Interview Questions
|Core Java Interview Questions||JSP Interview Questions|
|Java Servlets Interview Questions||EJB(Enterprise JavaBeans) Interview Questions|
|JSTL(JSP Standard Tag Library) Interview Questions||JNDI (Java Naming and Directory Interface) Interview Questions|
|Java Bean Utils Interview Questions||AWT (Abstract Window Toolkit) Interview Questions|
What Is Jdbc Programming?
Database Metadata, Part 1
Database Metadata, Part 2
Exploring Driver Property Information
Rowset Metadata A
Web Access To Metadata,part 1
Web Access To Metadata, Part 2
Rdf And Jdbc Metadata
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.