The datasource is a Spring bean. Create a bean of your own and have Spring inject the datasource. You can then plug that bean into your route before the JDBC step and use the exchange headers, which should contain the JMS headers, to update the properties of the datasource.
However, I think this design approach is asking for trouble:
- If you ever wanted to use a pooled data source (and you should), then you need to reset the pool of connections which is expensive
- You need to synchronize the state modifications of the (singleton) data source as it is not threadsafe in that respect and with Camel you are working in a multi-threaded framework
- You are sending user names and passwords for your DBs around the place and you should protect that information while it is in transit
There is probably more...