47. What is the difference between ResultSetMetaData and DatabaseMetaData

ResultSetMetaData
  • You can interrogate JDBC for detailed information about a query’s result set using a ResultSetMetaData object.
  • ResultSetMetaData is a class that is used to find information about the ResultSet returned from a executeQuery call.
  • It contains information about the number of columns, the types of data they contain, the names of the columns, and so on.
  • Two of the most common methods in the ResultSetMetaData are getColumnName and getColumnTypeName. These retrieve the name of a column, and the name of its associated data type, respectively, each in the form of a String.
DatabaseMetaData

DatabaseMetaData is a class that can be used to fetch information about the database you are using. Use it to answer questions such as:

  • What kind of catalogs are in the database?

  • What brand of database am I working with?

  • What username am I?

  • ex: username = dbmd.getUserName();

Advertisements

8 Responses

  1. good……………………….good

  2. it was understandable and simple

  3. Hi,

    Wonderful ….Its very useful at the time of Interview.

  4. thanks man………nice explaination

  5. its good

  6. I want the difference between ResultSet and ResultSetMetaData

  7. every thing is fine but
    ResultSetMetaData and DatabaseMetaData are the interfaces …and by using the references of these interfaces we can access the methods in it…..
    ex:
    ResultSet rs= statement.executeQuery(“sql query”);
    ResultSetMetadata rsmd = rs.getMetaData();

    rsmd.getColumnCount();
    rsmd.getColumnTypeName();

    by using ResultSetMetaData u can find the details of records available in the Resultset object…ex column names,datatype,size of the column

    by using DataBaseMetaData u can check the details of database server for which u r connectd…ex username,url,
    number of stored procedures available in database,tables of the currenct schema

  8. add more details about DataBaseMetaData..

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: