This is probably really simple or impossible.
I have an application written in Java SE which, to me, is a simple desktop application which connects to an oracle or sqlserver database. This all works and one of the paramaters I use to input switches to the appropriate database e.g.
To run it I do:
java -jar "D:\somefolder\Iwrauditmigration.jar useOracleArgument
where useOracleArgument is some parameter I use to specify the database.
This works on my PC (I use netbeans btw) and also works from the command line on the server this needs to work from.
The database is connected using driver manager e.g.
... string setup etc ...
conn = DriverManager.getConnection(url, "username", "xxxxxx");
I've now been asked to use a datasource type connection instead and I guess with a JNDI -as I would do for a servlet/Java EE application. Is this possible? I don't know why but this doesn't make sense to me i.e. running my jar file from the command line but using server based attributes. The reason to do this is to allow the command line parameters to point to the same datasource (i.e. sqlserver or oracle) but to point to different instances i.e. Live database, test or development.
So my question really is how to use the datasource I can set-up on a server in a Jar file called from the command line (by a cronjob). I could convert this all to EJBs or something but it was meant to be a quick job but the change to datasource has confused me. I imagine my problem is that I don't see how to do it on my dev PC with netbeans to test it out i.e. run a server and then use the command line app in the server context?? How does a desktop app see the JNDI definitions?
Don't count your weasels before they've popped. And now for a mulberry bush related tiny ad: