0
votes

Connect with different database server dynamically based upon flag or without flag and don't want to use choice connector to connect with other database server because we are using same database configuration more than 1000 times in our project using multiple database connectors. if we use choice connector, we need to apply everywhere in our project. e.g.

Flag True Connect with Oracle database server and Flag False Connect with SQL database server

1

1 Answers

2
votes

I assume Mule4. If you want this for Mule3 should be similar but instead of DataWeave expressions you will need to write MEL.

I was just able to hook to two different DBs, a MySQL and a Derby, using the following Database Config global element:

<db:config name="Database_Config" doc:name="Database Config" doc:id="af508698-f0a0-44fa-89ee-d67e5d0a5ee8" >
    <db:generic-connection url='#[if (false) "jdbc:mysql://hostname:3306/training?user=name&amp;password=pass" else "jdbc:derby://localhost:1527/memory:training"]' driverClassName='#[if (false) "com.mysql.jdbc.Driver" else "org.apache.derby.jdbc.ClientDriver"]' />
</db:config>

You have to ensure I have both JDBC drivers in your pom.xml.