Yes, you can change it couple different ways. However, first I want to tell you the recommended way. The recommended way is that you keep the data source's JNDI name constant when VDB is being migrated/promoted between environments like development/testing/production, that way there is no change to the VDB itself, but you are deploying the VDB with different -ds.xml in different environments with same JNDI name.
However, if you like to change the JNDI name for a source in the VDB, then first create -ds.xml with different JNDI name, then you can use
1) admin-console web administration application (http://localhost:8080/admin-console), go to "Data Services" tab and select your VDB and on VDB panel, you have option to change the "connection-jndi-name" on the model. Check Admin Guide admin-console chapter.
2) You can use Admin API and call "assignToModel" method to programmatically change it using Java program. Check the Admin Guide
3) You can use Admin Shell and use "assignToModel" method to change it using scripting in Groovy shell. Check the Admin Guide's admin-shell chapter.
Thanks Ramesh for the prompt reply.
I followed your suggestion and tried to change the connection programatically using the admin api in the following way;
AdminFactory adminFactory = AdminFactory.getInstance();
Admin admin = adminFactory.createAdmin("admin", "admin".toCharArray(), "mms://localhost:31443");
admin.assignToModel("Sample", 1, "SQLSourceA", "SQLSourceA", "sqlserver", "SQLSourceA_2");
Code worked without any error but the data source for the model is not changing. I tested it by doing a jdbc query before and after the call to assignToModel.
Is there something that I missed?
That looks correct. You can even check with code
VDB vdb = admin.getVDB("sample", 1); Model m = vdb.getModel("SQLSourceA"); String jndiName = m.getSourceConnectionJndiName("SQLSourceA");
You can also verify with "admin-console" as I mentioned. If you see the right names but still not seeing the results, then we need to look further. Also what version you are working with?
The code you suggested returns the updated information but querying still shows that the connection is not updated. I am using teiid 7.5.
Looks like bug due to regression. Can you log a JIRA https://issues.jboss.org/browse/TEIID ?
To workaround, if you re-start the server after the name change it will work as expected.