JDBC DatabaseMetaData

Google Advertisements

Prev Tutorial Next Tutorial

DatabaseMetaData in JDBC

This metadata interface is used for reading metadata about a database.

Metadata about database is nothing but reading database server, version, driver name and its version, maximum number of columns allowed in a table etc.

How to get the object of DatabaseMetaData

To obtain a object of DatabaseMetaData, we need to call getMetaData() method of Connection object.

Syntax

DatabaseMetaData dbms=con.getMetaData();

Methods of DatabaseMetaData

The methods to read some metadata information are:

methodDiscription
1getDatabaseProductName()To read database server name.
2getDatabaseProductVersion()To read database server version.
3getDriverName()To read driver software name.
4getColumnInTable()To find maximum number of columns allowed in the table..

Example of DatabaseMetaData

import java.sql.*;
class DBMetaDeta
{
public static void main(String[] args) throws Exception
{
Class.forName("oracle.jdbc.OracleDriver");
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@rama-pc:1521:xe","system","system");
System.out.println("conection is opened");
Statement stmt=con.createStatement();
DatabaseMetaData dbmd=con.getMetaData();
System.out.println("database server name:"+dbmd.getDatabaseProductName());
System.out.println("database server version:"+dbmd.getDatabaseProductVersion());
System.out.println("driver server version:"+dbmd.getDriverVersion());
System.out.println("driver server name:"+dbmd.getDriverName());
System.out.println("max columns:"+dbmd.getMaxColumnsInTable());
stmt.close();
con.close();
}
}

Prev Tutorial Next Tutorial

Google Advertisements

Buy This Ad Space @$50 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 8076671483

Pure VPN Privide Lowest Price VPN Just @ $1.65. Per Month with Non Detected IP Lowest Price Non Detected IP VPN

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet

Cloud computing is the on demand availability of computer system resources, especially data storage and computing power, without direct active management by the user. Cloud Computing Tutorial

College Projects Related to Java, AWT, C Projects for College, C++ Projects for College, Android Projects. Download Java C C++ Projects

Download Projects

Adsense Advertisements


Buy This ads Space 8076671483

Buy This Ad Space @$120 per Month, Ad Size 300X600 Contact on: hitesh.xc@gmail.com or 8076671483 Try this Keyword C++ Programs