• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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


 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic