简体   繁体   English

MULE中的Oracle数据源配置(AnyPoint Studio)

[英]Oracle Data source configuration in MULE(AnyPoint Studio)

I use this config for oracle database in Mule: 我在Mule中使用此配置为oracle数据库:

    <spring:beans>               
    <spring:bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" destroy-method="shutdown" name="Bean">
        <spring:property name="driverName" value="oracle.jdbc.driver.OracleDriver"/>
        <spring:property name="url" value="jdbc:oracle:thin:@192.168.28.129:1521:orcl"/>
        <spring:property name="user" value="username" />
        <spring:property name="password" value="123456" />
    </spring:bean>
</spring:beans>


<db:oracle-config name="Oracle_Configuration" useXaTransactions="true" dataSource-ref="dataSource"   doc:name="Oracle Configuration">

    <db:pooling-profile maxPoolSize="10" minPoolSize="5" acquireIncrement="2"/>
</db:oracle-config>

*I added ojdbc14.jar as a external jar file into my project but when I test connection in Global Elements in Anypoint Studio I see this error: *我将ojdbc14.jar作为外部jar文件添加到我的项目中,但是当我在Anypoint Studio中的Global Elements中测试连接时,我看到了以下错误:

在此输入图像描述

在此输入图像描述

在此输入图像描述

how can I solve this issue? 我该如何解决这个问题?

Also I have to say that in a main method I checked the connection and it was ok, this is Main method structure: 另外我不得不说在一个主方法中我检查了连接并且没关系,这是Main方法结构:

    import java.sql.*;

public class Main {

    public static void main(String[] args) throws Exception {

           try {
                 Class.forName ("oracle.jdbc.driver.OracleDriver");
           } catch (ClassNotFoundException e) {
                 e.printStackTrace();
           }

            Connection conn = DriverManager.getConnection
                ("jdbc:oracle:thin:@192.168.28.129:1521:orcl", "eslami", "123456");
                                // @machineName:port:SID,   userid,  password

            Statement stmt = conn.createStatement();
            ResultSet rset = stmt.executeQuery("select * from person");
            while (rset.next())
                System.out.println (rset.getString(1) +  "  " + rset.getString(2) + "  " +  
                                    rset.getString(3) +  "  " + rset.getString(4) + "  " + 
                                    rset.getString(5));   // Print row 1
            stmt.close();
      }

}

This is how you can configure your oracle :- 这是你如何配置你的oracle: -

<spring:beans> 
<spring:bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"    destroy-method="close"> 
        <spring:property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/> 
        <spring:property name="url" value="jdbc:oracle:thin:@192.168.28.129:1521:xe"/> 
        <spring:property name="username" value="yourUserName"/> 
        <spring:property name="password" value="yourPassword"/> 
        <spring:property name="removeAbandoned" value="true"/> 
        <spring:property name="initialSize" value="10"/> 
        <spring:property name="maxActive" value="50"/> 
        </spring:bean> 
</spring:beans>

<db:generic-config name="Database_Configuration" dataSource-ref="dataSource" doc:name="Generic Database Configuration" />

 <flow name="mainFlow">
     <http:listener config-ref="httpListenerConfig" path="/*" doc:name="HTTP" allowedMethods="GET"/> 
///////////////////////////////////////

Your Code
////////////////////////////////////
 <db:select config-ref="Database_Configuration" doc:name="Database">
    <db:parameterized-query><![CDATA[select * from yourtableName]]></db:parameterized-query>
</db:select>
</flow>

You can use the above configuration and change as per your ip, username, password etc 您可以使用上述配置并根据您的IP,用户名,密码等进行更改

And don't forget to add commons-dbcp-1.2.2.jar or other version and ojdbc6.jar in your classpath 并且不要忘记在类路径中添加commons-dbcp-1.2.2.jar或其他版本和ojdbc6.jar

One clear difference from your working Java example and the non-working mule code is the XATransactions. 与您工作的Java示例和非工作的mule代码的一个明显区别是XATransactions。 Could you try turn them off and see if there is a difference? 你可以尝试关掉它们,看看是否有区别?

Otherwise, supply your version of Anypoint and Mule and I'll give this code a testrun. 否则,提供你的Anypoint和Mule版本,我会给这个代码一个testrun。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM