db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bernt M. Johnsen" <bernt.john...@sun.com>
Subject Re: Help reading transaction logs
Date Thu, 03 May 2007 11:08:46 GMT
Hi,

Don't know why you get a null result, it might be that you should position
after some preamble or something like that.

But, I'm curious about what you really want to achieve? There might be
better ways to do it than reading the transaction log.


Bernt

>>>>>>>>>>>> Andy Stewart wrote (2007-05-03 09:58:05):
> 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
> 

-- 
Bernt Marius Johnsen, Database Technology Group, 
Staff Engineer, Technical Lead Derby/Java DB
Sun Microsystems, Trondheim, Norway

Mime
View raw message