骡子MySQL连接器

时间:2014-03-10 08:32:58

标签: mysql mule

我正在尝试将Mule连接到MySQL数据库,使用本教程(非常新的Mule): http://www.mulesoft.org/connectors/mysql-connector

我一直走到第6步(测试列表项目)。如果我转到指定的URL,我收到此错误:

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

我现在已经搜索了很长时间,但我找不到解决方案。 也许你们可以帮助我吗?

有我的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>

尝试了最新的MySQL连接器(mysql-connector-java-5.1.29-bin)和本教程中所述的1。两者都不起作用。

有人知道如何解决这个问题:)?

谢谢! 巴特

2 个答案:

答案 0 :(得分:2)

错误消息显示为jdbc://selectAll,您的数据源网址似乎不正确。如果查看MySql Connector教程示例,则url应采用jdbc:mysql://localhost:3306/mulesoft_db的样式。

答案 1 :(得分:0)

此配置对我有用。

<db:generic-config name="Generic_Database_Configuration" url="jdbc:postgresql://localhost/isnews?password=postgres&amp;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"/>