In Mule 3, I can get the database connection using the following Java code snippet:
StaticDbConfigResolver staticDBConfig = org.mule.RequestContext.getEventContext().getMuleContext().getRegistry().lookupObject("Oracle_Configuration");
MuleEvent muleEvent = org.mule.RequestContext.getEvent();
GenericDbConfig genericDBConfig = (org.mule.module.db.internal.domain.database.GenericDbConfig)staticDBConfig.resolve(muleEvent);
Connection connection = genericDBConfig.getDataSource().getConnection();
How can I achieve the same in Mule 4 ?
I tried searching in Google, but I am not able to find anything.
Thanks, Sunny
The short answer is no. The internals of Mule 4 connectors are not exposed to applications. The design doesn't allow for custom Java code to access the connections nor any other implementation details. See https://docs.mulesoft.com/mule-sdk/latest/isolation#modules-classloading-isolation for more details.
Instead I recommend to ask a new question about the specific problem for which you are trying to get the connection to see if it could be implemented using Mule 4 features.