Search code examples
javamysqlmavenmulesoftanypoint-studio

Mulesoft Anypoint 7 . MYSQL missing MySQL driver class


It's a fundamental question but it's a really annoying issue when starting with mule

Error: "Cannot load class 'com.mysql.jdbc.Driver'". Caused by: java.sql.SQLException: Error trying to load driver: com.mysql.jdbc.Driver : Cannot load class 'com.mysql.jdbc.Driver': [ com.mysql.jdbc.Driver, Cannot load class 'com.mysql.jdbc.Driver': [ Class 'com.mysql.jdbc.Driver' blablablablablablablablablablablablablablablabla

That is very likely because I don't have the mysql connector jar as a pom dependency. But when I added it to the pom file, the error persisted and I could not find the way to force a dependencies update.

I added manually the library inside classpath but still not working.


Solution

  • The first step is remove ALL library or reference to a MySQL connector inside the proyect.

    So, when you go to setup your connection, will find something like next image:

    Mulesoft Enypoint 7 new Database Config

    Configure->Add maven Dependency

    This new windows has been open and you only need to place the right mysql version:

    Mulesoft Anypoint 7 - Setting up mysql Driver in the only way it works

    After that, just setup your connection and voilá!

    Mulesoft Anypoint 7 - Database config

    Curiosly, instead of a Success Connection Test, the error persists when the next flow component (Transform Message) tries to update metadata

    MuleSoft Anypoint 7 - Mysql Connector fails

    After one hour I restarted the IDE and Magic happens! It's working.