DataBaseMetaData
- JDBC DatabaseMetaData is an interface of
java.sql.*;package. - DatabaseMetaData is generally implemented by the Database application vendors to know the capability of Database Management System in combination with the driver based JDBC technology.
- This interface is the tool for the user who need to discover how to deal with underlying database.
- Some meta data methods returns the string in form of ResultSet object.
- Then we retrieve data from this object with getInt(), and getString() methods.
- Some metadata objects takes argument also.
- DatabaseMetaData provides comprehensive information about the database.
- This interface is implemented by the driver vendors to allow the user to obtain information about the tables of a relational database as a part of JDBC application.
- User can use this interface to deal with various underlying DBMSs.
- Some of the methods are:-
getDatabaseMajorVersion()getDatabaseMinorVersion()getDatabaseProductName()getDatabaseProductVersion()getMaxRowSize()getPrimaryKeys()getURL()getUserName()etc.
JDBC provides four interfaces that deal with database metadata
- java.sql.DatabaseMetaData: about the database as a whole: table names, table indexes, database product name and version, and actions the database supports.
- java.sql.ResultSetMetaData: about the types and properties of the columns in a ResultSet object.
- java.sql.ParameterMetaData: about the types and properties of the parameters in a PreparedStatement object.
- javax.sql.RowSetMetaData: about the columns in a RowSet object.
RowSet
- JDBC RowSet is an interface of
javax.sql.rowsetinterface. - This interface is wrapper around a ResultSet object that makes possible to use resultSet as java beans object.
- It can be one bean that makes available for composing of an application. Because a it continually maintain a connection JDBC connection to the database.
- Another advantage of JDBC RowSet is that it is used to makes ResultSet object scrollable and updateable.
- By default all the RowSet object are scrollable and updateable.
- An Example of Row Set Event listener is given below, To run this example at first create a database name student and create a table also named student
CREATE TABLE student ( RollNo int(9) PRIMARY KEY NOT NULL, Name tinytext NOT NULL, Course varchar(25) NOT NULL, Address text );
insert into student VALUES(1, 'Amit', 'BCA', 'Chennai') ; insert into student VALUES(2, 'Sumit', 'MCA', 'Mumbai') ;



