db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andy Stewart <andy.stew...@erudine.com>
Subject Help reading transaction logs
Date Thu, 03 May 2007 08:58:05 GMT
Can anybody help with how to read a transaction log written by derby in 
a jar?

I think the log consists of serialised Loggable objects and am trying to 
use the derby class files to read it back in. However when I point it at 
a transaction log (which is about 1mb big) I am not able to read any 
objects back.

The program I have got looks like:

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;

import org.apache.derby.iapi.services.io.FormatIdInputStream;

public class LogReader {

    private String logFileName;

    /**
     * @param args
     */
    public static void main( String[] args ) throws Exception {
        LogReader logReader = new LogReader( "C:\\Documents and 
Settings\\andy.stewart\\workspace_trunk\\DerbyInAJar\\derbyDB\\log\\log1.dat" 
);
        logReader.readLogFile();
    }

    public LogReader( String logFileName ) {
        this.logFileName = logFileName;
    }

    public void readLogFile() throws Exception {
        File file = new File( this.logFileName );
        System.out.println( "File exists: " + file.exists() );
        InputStream fileInputStream = new FileInputStream( file );
        FormatIdInputStream formatIdInputStream = new 
FormatIdInputStream(fileInputStream);
        Object object = formatIdInputStream.readObject();
       
        System.out.println(object);
    }
}

The output is as follows:
    File exists: true
    null

Could anybody shed any light on what I should be doing to read these 
logs files in?

Thanks,
Andy


Mime
View raw message