JDBC Tutorial

JDBC Metadata

Data about data is metadata.

  • Database Metadata
  • Parameter Metadata
  • ResultSet Metadata

Database Metadata

Retrieves a DatabaseMetaData object that contains metadata about the database to which this Connection object represents a connection. The metadata includes information about the database's tables, its supported SQL grammar, its stored procedures, the capabilities of this connection, and so on.

 	    DatabaseMetaData dbMeta = connection.getMetaData();

ResultSet Metadata

Resultset object has rs.getMetaData() method

    			ResultSet rs  =  stmt.executeQuery(sql);
    			ResultSetMetaData rsMetaData = rs.getMetaData();

Parameter MetaData

     Parameter Metadata available on parametarized queries. such as PreparedStatement and CallableStatement objects. Programmer can find out , parameter name, type, scale,precision, in case of stored procedures, mode of the parameter, type etc.,

    			ParameterMetaData paramMeta =  	pstmt.getParameterMetaData()