Create a Java application that connects to a MariaDB database, creates a table called "employees", inserts sample employee records, and retrieves all records from the table sorted by last name.

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

1. A running instance of MariaDB server
2. The MariaDB JDBC driver (you can download it from https://mariadb.com/downloads/#connectors)
3. Add the downloaded JDBC driver JAR file to your project's classpath

Here is an example Java application that demonstrates how to connect to a MariaDB database, create a table called "employees", insert sample employee records, and retrieve all records from the table sorted by last name.

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

public class MariaDBExample {

    public static void main(String[] args) {
        String url = "jdbc:mariadb://localhost:3306/your_database_name";
        String user = "your_username";
        String password = "your_password";

        try {
            // Connect to the MariaDB database
            Connection connection = DriverManager.getConnection(url, user, password);
            Statement statement = connection.createStatement();

            // Create the "employees" table
            String createTableSql = "CREATE TABLE IF NOT EXISTS employees (" +
                    "id INT AUTO_INCREMENT PRIMARY KEY," +
                    "first_name VARCHAR(50)," +
                    "last_name VARCHAR(50))";
            statement.executeUpdate(createTableSql);

            // Insert sample employee records
            String insertEmployee1 = "INSERT INTO employees (first_name, last_name) VALUES ('John', 'Doe')";
            String insertEmployee2 = "INSERT INTO employees (first_name, last_name) VALUES ('Jane', 'Smith')";
            statement.executeUpdate(insertEmployee1);
            statement.executeUpdate(insertEmployee2);

            // Retrieve all records from the "employees" table sorted by last name
            String selectEmployeesSql = "SELECT * FROM employees ORDER BY last_name";
            ResultSet resultSet = statement.executeQuery(selectEmployeesSql);

            // Print the retrieved records
            System.out.println("Employees:");
            while (resultSet.next()) {
                int id = resultSet.getInt("id");
                String firstName = resultSet.getString("first_name");
                String lastName = resultSet.getString("last_name");

                System.out.printf("%d: %s %s%n", id, firstName, lastName);
            }

            // Close resources
            resultSet.close();
            statement.close();
            connection.close();

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

Replace `your_database_name`, `your_username`, and `your_password` with your actual MariaDB database name, username, and password. Make sure to include the MariaDB JDBC driver JAR file in your project's classpath.

This example assumes that you have a running instance of MariaDB server on your local machine (localhost) listening on the default port 3306. If your MariaDB server is running on a different host or port, update the `url` variable accordingly.