How to Use Metadata in a Database
The Microsoft SQL metadata is the data information that describes the database such as the driver version, product name and the database product name. You use this data when programming an application that manages database servers. The metadata "DatabaseMetaData" class retrieves the metadata for a database so that you can use it in your apps.
Instructions
-
-
1
Open your programming editor and open the main project you want to use to display the metadata. Double-click the file you want to use to display the data.
-
2
Instantiate the class. Instantiating the class loads it into memory and makes all of the class methods available. You must assign a variable for the class. The following code instantiates the class and assigns it to the "metadata" variable:
DatabaseMetaData metadata = connection.getMetaData();
The "connection" variable is your database connection string object.
-
-
3
Retrieve the metadata. The following code gets the driver version for your database:
string driver = metadata.getDriverVersion()
-
4
Display the metadata to the user. The following code displays the database's driver version to the user:
System.out.println("Driver version: " + driver);
-
1