Skip to content
jgp.ai
  • Home
  • Technology
    • Software Engineering
      • A few Guidelines for a Successful Software Project
    • Data
      • Data Mesh
      • Spark in Action, 2e
    • Architecture
      • A few Guidelines for a Successful Software Project
  • Business
  • Conferences & public speaking
  • Shop
  • About jgp
    • About jgp
    • Conferences & public speaking engagements
    • Publications
    • Interviews & Press Coverage
    • Shop
    • Contact

menu

  • Home
  • Technology
    • Software Engineering
      • A few Guidelines for a Successful Software Project
    • Data
      • Data Mesh
      • Spark in Action, 2e
    • Architecture
      • A few Guidelines for a Successful Software Project
  • Business
  • Conferences & public speaking
  • Shop
  • About jgp
    • About jgp
    • Conferences & public speaking engagements
    • Publications
    • Interviews & Press Coverage
    • Shop
    • Contact

DataFriday: what is Metadata?

Posted by, Jean-Georges Perrin on May 1, 2020
Metadata is like the foundation of your data
Metadata is like the foundation of your data

In this episode, I will explain what is metadata, at least, some metadata, more specifically metadata on relational databases. It’s a quick introduction.

I will also run a small Java lab to extract metadata from PostgreSQL using JDBC. The tools used are Eclipse, Java, and PostgreSQL.

I am using the JDBC DatabaseMetaData interface, implemented by driver vendors to let users know the capabilities of a database management system (DBMS) in combination with the driver based on JDBC technology (“JDBC driver”). Different RDBMSs (relational database management system) often support different features, implement features in different ways, and use different data types.

In addition, a driver may implement a feature on top of what the DBMS offers. Information returned by methods in this interface applies to the capabilities of a particular driver and a particular DBMS working together.

The code is available on GitHub.

For convenience, the Java code is added here. You will see the main steps of this small application:

  1. Get a JDBC connection.
  2. Access the metadata.
  3. Browse through tables and views.
package net.jgp.labs.jdbc.lab400_postgresql_metadata_dump;

import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Lists all tables in a specific database
 * 
 * @author jgp
 */
public class PostgresSqlListTablesApp {
	private static final Logger log = LoggerFactory.getLogger(PostgresSqlListTablesApp.class);

	/**
	 * main() is your entry point to the application.
	 * 
	 * @param args
	 */
	public static void main(String[] args) {
		PostgresSqlListTablesApp app = new PostgresSqlListTablesApp();
		app.start();
	}

	/**
	 * The processing code.
	 */
	protected boolean start() {
		log.debug("-> start()");

		String database = "spark_labs";
		String username = "postgres";
		String password = "Spark<3Java";
		String url = "jdbc:postgresql://localhost/";

		Connection connection;
		try {
			connection = DriverManager.getConnection(url + database, username, password);
		} catch (SQLException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
			return false;
		}

		DatabaseMetaData metadata;
		try {
			metadata = connection.getMetaData();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return false;
		}

		String[] types = { "TABLE", "VIEW" };

		ResultSet tablesRs;
		try {
			tablesRs = metadata.getTables(null, null, "%", types);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return false;
		}

		try {
			while (tablesRs.next()) {
				log.info("Table/view name ... {}", tablesRs.getString("TABLE_NAME"));
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return true;
	}
}

This is a basic metadata extraction process, but it illustrates the basics.

More resources:

  • Javadoc for the DatabaseMetaData interface.

The YouTube channel for DataFriday lists all episodes. You can attend the live show every Friday morning at 8 AM EST on Zoom.

Help share:

  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on X (Opens in new window) X
  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to email a link to a friend (Opens in new window) Email
  • More
  • Click to print (Opens in new window) Print
  • Click to share on Reddit (Opens in new window) Reddit
  • Click to share on Tumblr (Opens in new window) Tumblr
  • Click to share on Pinterest (Opens in new window) Pinterest
  • Click to share on Pocket (Opens in new window) Pocket
  • Click to share on Telegram (Opens in new window) Telegram
  • Click to share on WhatsApp (Opens in new window) WhatsApp

Like this:

Like Loading...
Posted in Data, News, TechWork, ToolsTagged DatabaseMetaData, DataFriday, Java, Metadata, PostgreSQL

Post navigation

← DataFriday: basic ETL ops with Apache Spark
DataFriday: extracting metadata from photos →

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 1,575 other subscribers

Jean-Georges Perrin is the author of Spark in Action, second edition, published by Manning.

Spark in Action, Second Edition

Help share:

  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on X (Opens in new window) X
  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to email a link to a friend (Opens in new window) Email
  • More
  • Click to print (Opens in new window) Print
  • Click to share on Reddit (Opens in new window) Reddit
  • Click to share on Tumblr (Opens in new window) Tumblr
  • Click to share on Pinterest (Opens in new window) Pinterest
  • Click to share on Pocket (Opens in new window) Pocket
  • Click to share on Telegram (Opens in new window) Telegram
  • Click to share on WhatsApp (Opens in new window) WhatsApp

Recent Posts

  • The I in IBM stands for Inspiration, and the M for Massachusetts
  • Bitol Winter Party 2024
  • Data Product vs. Data Contract: What’s the Difference?
  • Is DeepSeek an Enormous Geopolitical Teasing?
  • Defining Data Products: A Community Effort

Tag Cloud

4GL AI Alsace Analytics Apache Spark Benchmark Best Practice Big Data Chapel Hill, NC Conference CSV Data Databricks Dataframe DataFriday Data Mesh Data Quality EGL GreenIvory Hortonworks IBM IDUG IIUG Informix Java Medium Microsoft NC PayPal PostgreSQL Publication Raleigh, NC Raspberry Pi Spark Spark Summit Spark v2.0 Spark v2.2 Spark v2.3 Spark with Java Tools UX Web XML YouTube Zhamak Dehghani

Categories

  • Architecture (12)
  • Business (13)
  • Data (102)
  • Internal Articles (11)
  • News (59)
  • Personal (16)
  • Software Engineering (29)
  • TechWork (59)
  • Tools (17)
  • Web (8)




Archives

  • May 2025 (1)
  • February 2025 (2)
  • January 2025 (2)
  • November 2024 (2)
  • October 2024 (4)
  • September 2024 (1)
  • August 2024 (2)
  • July 2024 (1)
  • June 2024 (3)
  • May 2024 (4)
  • March 2024 (1)
  • February 2024 (1)
  • December 2023 (1)
  • October 2023 (4)
  • August 2023 (1)
  • June 2023 (1)
  • May 2023 (2)
  • March 2023 (6)
  • February 2023 (3)
  • January 2023 (2)
  • December 2022 (1)
  • August 2022 (2)
  • January 2022 (1)
  • December 2021 (1)
  • November 2021 (1)
  • October 2021 (11)
  • September 2021 (2)
  • May 2021 (1)
  • February 2021 (1)
  • July 2020 (3)
  • June 2020 (2)
  • May 2020 (3)
  • April 2020 (2)
  • May 2019 (1)
  • April 2019 (1)
  • March 2019 (1)
  • February 2019 (2)
  • January 2019 (2)
  • December 2018 (2)
  • October 2018 (1)
  • September 2018 (2)
  • August 2018 (1)
  • July 2018 (2)
  • April 2018 (1)
  • March 2018 (1)
  • October 2017 (3)
  • September 2017 (3)
  • July 2017 (2)
  • June 2017 (2)
  • April 2017 (2)
  • March 2017 (1)
  • February 2017 (2)
  • December 2016 (1)
  • November 2016 (1)
  • October 2016 (1)
  • September 2016 (1)
  • August 2016 (2)
  • July 2016 (6)
  • June 2016 (4)
  • May 2016 (1)
  • April 2016 (3)
  • March 2016 (8)
  • February 2016 (4)
  • January 2016 (1)
  • March 2015 (1)
  • December 2014 (1)
  • October 2014 (1)
  • July 2014 (2)
  • June 2014 (3)
  • May 2014 (1)
  • April 2014 (1)
  • March 2014 (1)
  • February 2014 (2)
  • January 2014 (3)
  • February 2010 (1)
  • May 2008 (1)
  • April 2008 (1)
  • December 2007 (1)
  • October 2007 (2)
  • August 2007 (1)
  • May 2007 (2)
  • April 2007 (2)
  • February 2007 (3)
  • January 2007 (3)
  • December 2006 (5)
  • November 2006 (1)
  • October 2006 (7)
  • September 2006 (8)
  • August 2006 (8)
  • July 2006 (3)
  • June 2006 (5)
  • April 2006 (2)
  • March 2006 (2)
  • November 2005 (3)

Permatechlinks

  • Comparison of microSD Card Performance on the Raspberry Pi Did you think that all microSD cards were born equal?
  • A few Guidelines for a Successful Software Project My career as a project manager and architect summarized in this pragmatic guidelines.
  • The Apache Ecosystem for Enterprise Applications A list of Apache components to build enterprise applications, including data stores, libraries, tools, and more.
  • Spark Java Recipes A few Java recipes to get started with Apache Spark
  • Getting Started with AngularJS A quick intro to your first AngularJS app.
Let's be social
@jgperrin
/jgperrin
/jgperrin
 

Loading Comments...
 

    %d