You can use dependency injection and inject a DataSourcePool into an AEM Service. Once you successfully inject a DataSourcePool into an AEM service, you can use SQL commands to interact with MySQL. For information on how to work with DataSourcePools in AEM, see this community article:
Injecting a DataSourcePool Service into an Adobe Experience Manager OSGi bundle