MobileFirst Java SQL Adapter with Java EE DataSource
DougBreaux 270007SMYJ Visits (5412)
Minor addition to the MobileFirst Foundation Java SQL Adapter tutorial.
I really don't want to be hardcoding Database configuration in my adapters. Or repeating it for multiple adapters that share the same Database access. (Not to mention not wanting to require the referenced Apache BasicDataSource class and libraries either.)
And since MobileFirst Foundation runs on a Java EE server anyway, why would I not use DataSources configured as server Resources?
(Here's the WebSphere Liberty way to do this: Conf
So I use java
I'll still put the JNDI name itself in Adapter configuration parameters:
Now, in a "DAO" class that I instantiate (as a singleton) from my Resource class (or could do from the Application class), I use the following simple code to obtain that DataSource:
Where dataSourceJndiName is obtained from the ConfigurationAPI: