Mendix has published a Database Connector module, which actually includes the Java Action you are looking for. So you don't have to develop (and maintain) this one yourself! Just download this module and put the JDBC-driver you need (.jar-file) in the userlib folder of your project.
See documentation here: https://docs.mendix.com/appstore/connectors/database-connector
Download module from the app store here: https://appstore.home.mendix.com/link/app/2888/