wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Changing from command line Java to server based to take advantage of datasources Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Changing from command line Java to server based to take advantage of datasources" Watch "Changing from command line Java to server based to take advantage of datasources" New topic
Author

Changing from command line Java to server based to take advantage of datasources

jason bailey
Greenhorn

Joined: Apr 21, 2009
Posts: 9
Hello
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?

Jason


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Changing from command line Java to server based to take advantage of datasources