Informix Object Interface for Java, scheduled prog won't work
Posted in 1998
Topics: Security, Permissions & Auditing, Java & JDBC Development
I have the following task: run a program each day at a specific time. The program has to read values from an Informix DB, compute stuff and produce reports. I have used the following programs: The whole program runs on NT4.0 - Informix Object Interface for Java API - to make the connection to the DB and perform the select's - Java (jdk116) for the overall computations and for producing the reports. - a batch file (TempoRenal.bat) that calls the java program - to schedule the batch file, I have used the "AT" command (at 15:45 /every .... cmd /c TempoRenal.bat) When I start "cmd /c TempoRenal.bat" from a Dos Shell, everything works fine. When it is started via the scheduler, building the credentials for the connection fails with a NullPointerException. I have previously noted that it is necessary to correctly configure a user with the Informix SetNet utility (setnet version 9.14). Since the scheduled program runs as "system" not as any user, the problem might be right there. My questions: - is there any way to propagate the configurations of setnet for some user to the "System" environment? - can I specifiy /set the user for the program that is scheduled with the "AT"-command? - Is there some other way of building a connection with Informix Object Interface for Java without relying on setnet-parameters? Below is the java code to build the connection (exception handling etc omitted): (The code is adapted from the online documentation examples) Thanks for help and infos! Sylvia Schleutermann ======================== Connection connection, Query query; Credentials credentials; // Build credentials for db nimon, user nimon, //password fakepasswd, server opserver credentials = new DirectCredentials ("nimon", "nimon", "opserver", "fakepasswd"); // -----> this is where the NullPointerException happens // query is shortened String queryText = "select aufnahme_nr from sammelperiode where abnahmedatum = \\"today\\""; connection = credentials.connection(); query = connection.query(); connection.open(); if (!query.execForIteration (queryText)) { System.out.println ("Query " + queryText + " is not executable!"); return null; } // from here on, the rows of the result set are processed ... =============================================