Category: Java

Determine Last Update Date of a File

We have had trouble with our interface picking up the wrong file.  The client thinks they have put the file in the right place, but the server is looking at a different file for some reason.  Placing the date/time in the standard output helps identify these situations.  Here is how you can do that:

Local JavaObject &javaFile;
Local JavaObject &javaFormat;

&javaFile = CreateJavaObject(“java.io.File”, “c:\temp\myFile.txt”);
&javaFormat = CreateJavaObject(“java.text.SimpleDateFormat”, “yyyy/MM/dd hh:mm:ss aa”);
MessageBox(0, ” “, 0, 0, File Timestamp: %1”, &javaFormat.format(&javaFile.lastModified()));

Writing to Access Databases

We are thinking about connecting to an Access database for one of our interfaces.  Here is some PeopleCode that I threw together to make sure that it was possible.

I tested the code in a VMWare instance with HCM8.9/Tools 8.46, Windows Server 2003.  The instance did not have Microsoft Access installed, and I changed the path (c:\temp\AccessTest.mdb below) to a network (UNC) path where the computer had Access installed.

Local JavaObject &class;
Local JavaObject &connection;
Local JavaObject &driverManager;
Local JavaObject &statement;

&class = GetJavaClass("java.lang.Class");
&class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

&driverManager = GetJavaClass("java.sql.DriverManager");
&connection = &driverManager.getConnection("jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=c:\temp\AccessTest.mdb;DriverID=22;READONLY=false");
&statement = &connection.createStatement();
&statement.executeUpdate("insert into tblTest(TestMessage) values ('testing')");

Hope it helps.

Resources