我有一个xml文件: -
< getData >
< Data >
< id >321< /id >
< name >aa< /name >
< age >23< /age >
< designation >gfgf< /designation >
< /Data >
< /getData >
ID 和 AGE 是整数.....现在我想使用Mule在数据库中插入xml的这些属性...我的Mule流程是: -
< context:property-placeholder location="classpath:conf/DBConnectionProp.properties"/>
< spring:beans>
< spring:bean id="DB_Source" name="DB_Source" class="org.enhydra.jdbc.standard.StandardDataSource">
< spring:property name="url" value="${url}"/>
< spring:property name="driverName" value="${driverName}"/>
</spring:bean>
< /spring:beans>
< jdbc-ee:connector name="Database-Connector" dataSource-ref="DB_Source" validateConnections="true" queryTimeout="-1" pollingFrequency="0" doc:name="Database">
< jdbc-ee:query key="InsertQuery" value="INSERT INTO "getData"(ID,NAME,AGE,DESIGNATION)VALUES (#[xpath('//id').text],#[xpath('//name').text],#[xpath('//age').text],#[xpath('//designation').text])"></jdbc-ee:query>
< /jdbc-ee:connector>
<file:connector name="File_Input" autoDelete="false" streaming="true" validateConnections="true" doc:name="File"/>
<flow name="testxmlFlow1" doc:name="testxmlFlow1">
< file:inbound-endpoint path="E:\backup\test" responseTimeout="10000" doc:name="File" moveToPattern="Input.xml" connector-ref="File_Input"></file:inbound-endpoint>
< byte-array-to-string-transformer doc:name="Byte-Array-to-String" >< /byte-array-to-string-transformer >
< splitter evaluator="xpath" expression="/getData/Data" doc:name="Splitter" >< /splitter >
< jdbc-ee:outbound-endpoint exchange-pattern="one-way" queryKey="InsertQuery" queryTimeout="-1" connector-ref="Database-Connector" doc:name="Database"></jdbc-ee:outbound-endpoint >
< /flow >
请帮助.....我得到以下例外: -
Root Exception stack trace:
org.xml.sax.SAXParseException; lineNumber: 4; columnNumber: 2; The markup in the document following the root element must be well-formed.
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1236)
at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:485)
at org.mule.module.xml.transformer.XmlToDomDocument.transformMessage(XmlToDomDocument.java:63)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
如何插入ID和Age为Int ????
的值答案 0 :(得分:0)
现在正在工作....实际上我必须添加
<file:filename-regex-filter pattern="Input.xml" caseSensitive="false"/>
...它运行良好,仅接收&#34; Input.xml&#34;因此现在没有例外...之前它正在挑选文件夹中的所有文件,因此引发了异常