Create a Java application that connects to a PostgreSQL database, inserts sample data into a table, and then retrieves and displays the data on the console.

To create a Java application that connects to a PostgreSQL database, you will need the following:

1. A PostgreSQL server with an existing database.
2. The JDBC driver for PostgreSQL (you can download it from https://jdbc.postgresql.org/download.html).
3. Add the downloaded JAR file to your project's classpath.

Here is a sample Java application that connects to a PostgreSQL database, inserts sample data into a table, and then retrieves and displays the data on the console:

```java
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class Main {
    public static void main(String[] args) {
        // Replace these values with your own database connection details
        String url = "jdbc:postgresql://localhost:5432/mydatabase";
        String user = "myuser";
        String password = "mypassword";

        try {
            // Load the PostgreSQL JDBC driver
            Class.forName("org.postgresql.Driver");

            // Connect to the database
            Connection conn = DriverManager.getConnection(url, user, password);

            // Create a statement object
            Statement stmt = conn.createStatement();

            // Create a sample table
            String createTableQuery = "CREATE TABLE IF NOT EXISTS users (" +
                    "id SERIAL PRIMARY KEY," +
                    "name VARCHAR(50)," +
                    "email VARCHAR(100))";
            stmt.executeUpdate(createTableQuery);

            // Insert sample data into the table
            String insertDataQuery = "INSERT INTO users (name, email) VALUES ('John Doe', 'john.doe@example.com')";
            stmt.executeUpdate(insertDataQuery);

            // Retrieve and display the data from the table
            String selectDataQuery = "SELECT * FROM users";
            ResultSet rs = stmt.executeQuery(selectDataQuery);

            while (rs.next()) {
                int id = rs.getInt("id");
                String name = rs.getString("name");
                String email = rs.getString("email");
                System.out.println("ID: " + id + ", Name: " + name + ", Email: " + email);
            }

            // Close the resources
            rs.close();
            stmt.close();
            conn.close();

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
```

Replace the `url`, `user`, and `password` variables with your own database connection details. When you run this application, it will create a table called `users` if it doesn't already exist, insert sample data into the table, and then retrieve and display the data on the console.

Make sure to add the PostgreSQL JDBC driver JAR file to your project's classpath before running the application.