-
1. Re: How can i set the connection programatically for source model in a VDB?
rareddy Nov 10, 2011 9:19 AM (in response to fihtisham)Farrukh,
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.
HTH.
Ramesh..
-
2. Re: How can i set the connection programatically for source model in a VDB?
fihtisham Nov 11, 2011 7:38 AM (in response to rareddy)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?
Thanks,
Farrukh
-
3. Re: How can i set the connection programatically for source model in a VDB?
rareddy Nov 11, 2011 11:10 AM (in response to fihtisham)Farrukh,
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?
Ramesh..
-
4. Re: How can i set the connection programatically for source model in a VDB?
fihtisham Nov 14, 2011 3:55 AM (in response to rareddy)Thanks Ramesh!
The code you suggested returns the updated information but querying still shows that the connection is not updated. I am using teiid 7.5.
Thanks,
Farrukh
-
5. Re: How can i set the connection programatically for source model in a VDB?
rareddy Nov 14, 2011 10:52 AM (in response to fihtisham)Farrukh,
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.
Ramesh..