Reputation: 23
I'm trying to connect Mule to a MySQL database, using this tutorial (very new in to Mule): http://www.mulesoft.org/connectors/mysql-connector
I've come all the way down, to step 6 (Test listitems). If I go to the URL specified, i'm getting this error:
Failed to route event via endpoint: DefaultOutboundEndpoint{endpointUri=jdbc://selectAll, connector=EEJdbcConnector
{
name=Database
lifecycle=start
this=5b3808ad
numberOfConcurrentTransactedReceivers=4
createMultipleTransactedReceivers=false
connected=true
supportedProtocols=[jdbc]
serviceOverrides=<none>
}
, name='endpoint.jdbc.selectAll', mep=REQUEST_RESPONSE, properties={queryTimeout=-1}, transactionConfig=Transaction{factory=null, action=INDIFFERENT, timeout=0}, deleteUnacceptedMessages=false, initialState=started, responseTimeout=10000, endpointEncoding=UTF-8, disableTransportTransformer=false}. Message payload is of type: String
I've been searching for quite a long time now, but I can't find a solution. Maybe you guys can help me out?
There is my XML:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:jdbc-ee="http://www.mulesoft.org/schema/mule/ee/jdbc" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.4.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ee/jdbc http://www.mulesoft.org/schema/mule/ee/jdbc/current/mule-jdbc-ee.xsd">
<jdbc-ee:mysql-data-source name="MySQL_Data_Source" user="$(db.user)" password="$(db.password)" url="$(db.connection_string)" transactionIsolation="UNSPECIFIED" doc:name="MySQL Data Source"/>
<jdbc-ee:connector name="Database" dataSource-ref="MySQL_Data_Source" validateConnections="true" queryTimeout="-1" pollingFrequency="0" doc:name="Database">
<jdbc-ee:query key="selectAll" value="SELECT * FROM demo_tbl"/>
<jdbc-ee:query key="insertItem" value="INSERT INTO demo_tbl SET title=#[message.inboundProperties['title']], description=#[message.inboundProperties['description']]"/>
<jdbc-ee:query key="deleteItem" value="DELETE FROM demo_tbl WHERE id=#[message.inboundProperties['id']]"/>
<jdbc-ee:query key="findById" value="SELECT * FROM demo_tbl WHERE id=#[message.inboundProperties['id']]"/>
<jdbc-ee:query key="updateItem" value="UPDATE demo_tbl SET title=#[message.inboundProperties['title']], description=#[message.inboundProperties['description']] WHERE id=#[message.inboundProperties['id']]"/>
</jdbc-ee:connector>
<flow name="jdbc_demoFlow1" doc:name="jdbc_demoFlow1">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" path="list" doc:name="HTTP"/>
<jdbc-ee:outbound-endpoint exchange-pattern="request-response" queryKey="selectAll" queryTimeout="-1" connector-ref="Database" doc:name="Database"/>
<json:object-to-json-transformer doc:name="Object to JSON"/>
</flow>
</mule>
Tried the newest MySQL Connector (mysql-connector-java-5.1.29-bin), and the 1 stated in the tutorial. Both didn't work.
Anybody know how to fix this :)?
Thanks! Bart
Upvotes: 2
Views: 2691
Reputation: 455
This configuration is working for me.
<db:generic-config name="Generic_Database_Configuration" url="jdbc:postgresql://localhost/isnews?password=postgres&user=goncalodias" driverClassName="org.postgresql.Driver" doc:name="Generic Database Configuration">
</db:generic-config>
<db:mysql-config name="MySQL_Configuration" host="localhost" port="3306" user="root" password="passwd" database="IS" doc:name="MySQL Configuration"/>
Upvotes: 0
Reputation: 4015
The error message says jdbc://selectAll
, it looks like your data source url is incorrect. If you look at the MySql Connector tutorial example, the url should be in the style of jdbc:mysql://localhost:3306/mulesoft_db
.
Upvotes: 2