Win a copy of Rust Web Development this week in the Other Languages forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Exception initiating Driver in Cron Job

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
I am trying to run a Java application weekly that update database, and I am using Cron Job to do so.
The problem is I am trying to instantiate the Driver using

and got exception as output "com.mysql.jdbc.Driver" others are stack trace...
I have developed database application on the same environment over many times, this problem only occured now because I am using Cron Job.
I tried to set the class path to the jar file without success.
Does anyone have any experience similar to this, and have found a solution?
Please help. Thanks.
 
author and iconoclast
Posts: 24203
44
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Cron jobs don't get the same environment variables as you do when you log in; the precise details differ depending on your OS and shell, but basically, what you need to do is have the cron job invoke a shell script. In that shell script, either define things like the CLASSPATH, the PATH, etc, directly, or source in the init files that define them directly (i.e., "source ~/.bashrc", for example). Don't have the cron job assume anything about the environment.
 
Steven Ho
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have added the entire complete classpath
CLASSPATH=.:/usr/local/jdk/lib/classes.zip:/usr/local/jakarta/lib/activation.jar:/usr/local/jakarta/lib/cimapi.jar:/usr/local/jakarta/lib/client.jar:/usr/local/jakarta/lib/crimson.jar:/usr/local/jakarta/lib/dom4j.jar:/usr/local/jakarta/lib/fscontext.jar:/usr/local/jakarta/lib/imap.jar:/usr/local/jakarta/lib/jaas.jar:/usr/local/jakarta/lib/jaxm-client.jar:/usr/local/jakarta/lib/jaxm.jar:/usr/local/jakarta/lib/jaxr-api.jar:/usr/local/jakarta/lib/jaxr-apidoc.jar:/usr/local/jakarta/lib/jaxr-browser. jar:/usr/local/jakarta/lib/jaxr-ri.jar:/usr/local/jakarta/lib/jaxrpc-api.jar:/usr/local/jakarta/lib/jaxrpc-ri.jar:/usr/local/jakarta/lib/jcert.jar:/usr/local/jakarta/lib/jdbc2_0-stdext.jar:/usr/local/jakarta/lib/jmx_remoting.jar:/usr/local/jakarta/lib/jmxgrinder.jar:/usr/local/jakarta/lib/jmxri.jar:/usr/local/jakarta/lib/jmxtools.jar:/usr/local/jakarta/lib/jndi.jar:/usr/local/jakarta/lib/jnet.jar:/usr/local/jakarta/lib/jsse.jar:/usr/local/jakarta/lib/jta.jar:/usr/local/jakarta/lib/ldap.jar:/usr/ local/jakarta/lib/log4j.jar:/usr/local/jakarta/lib/mail.jar:/usr/local/jakarta/lib/mailapi.jar:/usr/local/jakarta/lib/mm.mysql-2.0.11-bin.jar:/usr/local/jakarta/lib/mof2mbean.jar:/usr/local/jakarta/lib/mofcomp.jar:/usr/local/jakarta/lib/pop3.jar:/usr/local/jakarta/lib/providerutil.jar:/usr/local/jakarta/lib/relaxer.jar:/usr/local/jakarta/lib/smtp.jar:/usr/local/jakarta/lib/soap.jar:/usr/local/jakarta/lib/tyrex-0.9.7.0.jar:/usr/local/jakarta/lib/xalan.jar:/usr/local/jakarta/lib/xerces.jar:/usr/lo cal/jakarta/lib/xercesSamples.jar:/usr/local/jakarta/lib/xml.jar
The exception is gone, but no output either
Anyway thanks for the help. Have a nice day.
 
Ernest Friedman-Hill
author and iconoclast
Posts: 24203
44
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should pipe the output to a file.
 
reply
    Bookmark Topic Watch Topic
  • New Topic