Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2002
    Location
    Tokyo
    Posts
    6

    Unanswered: PostgreSQL DB, Java Interface, Cron = errors...

    I am more or less new to using cron, and I am trying to automate a log cleaning system I have made. The system basically cleans through WWW logs that are mounted on an NFS and creates text files for entry into a local PostgreSQL DB.

    For the past year I have been running the various scripts and programs I have created for this task from the terminal daily. Everything worked just fine. However, when tried to do this all by cron the other day, I found I could not insert into my PostgreSQL DB using its JAVA interface. I get the following errors:

    Exception in thread "main" java.lang.NoClassDefFoundError: /Users/admin/LOGS/Insert_data

    The flow of the insert routine that I use runs as follows:

    01_insert_data.csh -> 01_insert_data.pl -> Insert_data.class
    (call one site at a time) (lists up non-inserted files) (inserts data into DB)

    I have set all of the paths I use in the above file to absolute paths, so this should not be an issue. I have set the env in 01_insert_data.csh to point to where the class files are. Yet no matter what I do, when I pass strings from 01_insert_data.pl to Insert_data.class I get the above NoClassDefFoundError error. I would appreciate some advice as to what I might try to fix this situation.

    BTW, the Insert_data.class is based on the simplied java program listed below. It seems that this programs never makes it beyond " public static void main (String argv[]) " line after it is called. Why would this be so from cron, and not from the terminal?

    ==========================
    import java.sql.*;
    import java.io.*;
    import java.lang.String;
    import java.util.*;

    public class Insert_data {
    public static void main(String argv[]) throws Exception {
    File ofile = new File(argv[0]);
    Class.forName("org.postgresql.Driver");
    Connection conn = DriverManager.getConnection("jdbc:
    postgresql:log_access","postgres","nobody");
    PreparedStatement ps = conn.prepareStatement("INSERT INTO access_m values (?, ?, ?, ?, ?, ?, ?)");
    try{
    FileReader fr = new FileReader (ofile);
    BufferedReader in = new BufferedReader (fr);
    String line;
    while( (line = in.readLine()) != null) {
    StringTokenizer st = new StringTokenizer (line);
    if( st.countTokens() < 8) {
    ps.setString(1,st.nextToken());
    .
    .
    ps.executeUpdate();
    }
    }
    }
    catch( FileNotFoundException e) {
    System.out.println("File Disappeared");
    System.out.println(ofile);
    }
    }
    }
    ==========================
    Last edited by mntamago; 11-17-02 at 01:11.

  2. #2
    Join Date
    Sep 2001
    Location
    Vienna
    Posts
    400

    sorry

    I don't programm in java yet. Maybe someone knows the answer
    but you can post it in the jdbc newsgroup of postgresql .
    there you will get easier an answer.
    http://www.postgresql.org
    --Postgresql is the only kind of thing--

  3. #3
    Join Date
    Oct 2002
    Location
    Tokyo
    Posts
    6

    Re: sorry

    Originally posted by eperich
    I don't programm in java yet. Maybe someone knows the answer
    but you can post it in the jdbc newsgroup of postgresql .
    there you will get easier an answer.
    eperich

    Thank you for the advice. The thought never crossed my mind, so I will give it a try.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •