import java.sql.*; public class Main { public static void main(String[] args) { String url = "jdbc:mysql://localhost:3306/mydb"; String user = "root"; String password = "password"; try (Connection conn = DriverManager.getConnection(url, user, password)) { DatabaseMetaData metaData = conn.getMetaData(); System.out.println("Database name: " + metaData.getDatabaseProductName()); System.out.println("Database version: " + metaData.getDatabaseProductVersion()); System.out.println("Driver name: " + metaData.getDriverName()); System.out.println("Driver version: " + metaData.getDriverVersion()); } catch (SQLException e) { e.printStackTrace(); } } }In this example, we use the Connection object to connect to a database and obtain its metadata using Connection.getMetaData(). We then print some of the metadata information obtained through the DatabaseMetaData object. The package library for this method is java.sql.