I use this config for oracle database in Mule:
<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:
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:
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 :-
<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
And don't forget to add commons-dbcp-1.2.2.jar
or other version and ojdbc6.jar
in your classpath
One clear difference from your working Java example and the non-working mule code is the 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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.