This cannot be determined because they are completely different things. Maven is nothing but the client version and for which you are checking with MySQL -V is the server version. There is no need to match the JDBC client version exactly.
Rather, you have to ensure the server support for the client version that you used.
If you read its docs, 5.1.47 should support MySQL 5.61, 5.71, 8.0. But you can update the client to version 8.0 series, which is the official recommendation and should also work with your existing MariaDB version.
If you want to get more insights into SQL, checkout this SQL Course from Intellipaat.