【问题标题】:Mule MySQL Connector骡 MySQL 连接器
【发布时间】:2014-12-14 04:04:41
【问题描述】:

我正在尝试使用本教程将 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。两者都不起作用。

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

谢谢! 巴特

【问题讨论】:

  • 查看页面 roytuts.com/mule-jdbc-insert-example/

标签: mysql mule


【解决方案1】:

错误消息为jdbc://selectAll,您的数据源网址似乎不正确。如果你看一下 MySql 连接器教程示例,url 应该是jdbc:mysql://localhost:3306/mulesoft_db 的样式。

【讨论】:

  • 谢谢!查看了 SQL 数据源。来源很好,但用户没有工作。我为 Mule 创建了一个用户,主机为 Any(在 phpMyAdmin 中)。我将主机更改为 localhost,它工作正常。
【解决方案2】:

此配置对我有用。

<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"/>

【讨论】:

    猜你喜欢
    • 2013-01-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-19
    相关资源
    最近更新 更多