0
votes

I am using Studio 5.4 and working with a local MySQL database. I have configured a MySQL Configuration and the test connection works fine. When I run the server the endpoint fails to get a connection. I have verified that the mysql-connector-java-5.1.34-bin.jar is in the classpath. I have verified the username and password and run the insert statement successfully in MySQL workbench. I am at a loss of what to try next.

The exception:

Root Exception stack trace: java.sql.SQLException: Error trying to load driver: com.mysql.jdbc.Driver : com.mysql.jdbc.Driver at org.enhydra.jdbc.standard.StandardDataSource.getConnection(StandardDataSource.java:184) at org.enhydra.jdbc.standard.StandardDataSource.getConnection(StandardDataSource.java:144) at org.mule.module.db.internal.domain.connection.SimpleConnectionFactory.create(SimpleConnectionFactory.java:26) at org.mule.module.db.internal.domain.connection.RetryConnectionFactory$1.doWork(RetryConnectionFactory.java:46)

My config:

<flow name="insertErrorMessage">
    <logger level="INFO" doc:name="Logger" message="error messages to process"/>
    <set-variable variableName="errorMessage" value="#[exceptionMessage]" doc:name="Variable"/>
    <set-variable variableName="currentTime" value="#[server.dateTime]" doc:name="Variable"/>
    <set-variable variableName="selectQuery" value="${insert.error.message}" doc:name="Variable"/>
    <set-variable variableName="changeLogId" value="999" doc:name="Variable"/>
            <db:insert config-ref="MySQL_Configuration" doc:name="Insert Error Message">
        <db:dynamic-query><![CDATA[#[flowVars.selectQuery]]]></db:dynamic-query>
    </db:insert>    
</flow> 

and the connector:

db:mysql-config name="MySQL_Configuration" host="localhost" port="3306" user="xxxx_erp" password="passw0rd" database="xxxx_mule_dev" doc:name="MySQL Configuration"/>
2
Where exactly is mysql-connector-java-5.1.34-bin.jar located? - David Dossot
I have tried it in an external directory /home/vmuser/libs/ and internally /home/vmuser/AnypointStudio/workspace/.mule/lib/shared - calalli
Oh I thought the issue was when running the application in Mule, but you get the issue in Studio, right? Instead of manually add the JAR somewhere, did you try adding it to your pom.xml file? - David Dossot
Thank you David. I had not done so because the team I am working with had not needed to. But I just tried it and it resolved my issue. - calalli
Cool, I've turned this comment into an answer then :) - David Dossot

2 Answers

1
votes

Add the following to your project pom.xml:

<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>5.1.34</version>
</dependency>
0
votes

Add mysql connector jar in Build Path->configure build path->libraries