Any help on this would be appreciated.
State your jboss version. Since you didn't, I won't tell you what versions this applies to.
It's probably easier to create an xml file dynamically and deploy it by calling MainDeployer.deploy, but an example of creating a datasource entirely in code is in the testsuite
I am using JBOSS 3.0 RC3 on W2k.
This is really good help for me. Please provide the little more information how to do it and where is the example.