Re: Serialize

From: "Dave Cramer" <Dave(at)micro-automation(dot)net>
To: "'Tony Grant'" <tony(at)animaproductions(dot)com>
Cc: "'jdbc list'" <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: Serialize
Date: 2001-10-05 14:22:14
Message-ID: 001d01c14da9$219d1900$0301a8c0@inspiron
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Actually, no that's not what it's for.

What it does is "Serialize" a class into the db "automagically".

There are much better products out there with much better functionality

See http://www.ambysoft.com/persistenceLayer.html

I personally use Artom Rudoy's persistence layer

www.sourceforge.net/projects/player

The following code is an example of how to use Serialize in the postgres
database

package postgrestest;

/**
* Title: Postgres Tests
* Description:
* Copyright: Copyright (c) 2001
* Company: Ebox Inc
* @author Dave Cramer
* @version 1.0
*/

/*
* Java sample program
*/

import java.io.*;
import java.sql.*;
import org.postgresql.util.*;

public class lili implements Serializable
{

public String myString;
public int myNumber;

public lili() throws ClassNotFoundException, FileNotFoundException,
IOException, SQLException
{

myString="theString";
myNumber=4;
}
public boolean equals(lili l)
{
return (l.myString.equals(this.myString) && myNumber ==
this.myNumber);
}
private void testmethod(){};
public void testmethod2x(){};

public static void main(String args[])
{
org.postgresql.Connection conn=null;
try {
lili mylili = new lili();
lili test = null;
Class.forName("org.postgresql.Driver"); // load database
interface

// connect to the database
conn =
(org.postgresql.Connection)DriverManager.getConnection("jdbc:postgresql:
//alpha.ebox.com/davec", "davec", ""); // works
// test of serialisation
org.postgresql.util.Serialize.create(conn, mylili); // makes
problems
org.postgresql.util.Serialize s = new Serialize(conn,mylili);
int oid = s.store(mylili);
test = (lili)s.fetch(oid);
if (mylili.equals(test)){
System.out.println("Success");
}else{
System.out.println("Failure");
}
} catch(Exception exc){
System.err.println("Exception caught.\n" + exc);
exc.printStackTrace();
}finally{
try {
if (conn != null) conn.close();
} catch (Exception ex){
;
}
}
}

}

-----Original Message-----
From: Tony Grant [mailto:tony(at)animaproductions(dot)com]
Sent: October 5, 2001 9:34 AM
To: Dave(at)micro-automation(dot)net
Cc: jdbc list
Subject: Re: [JDBC] Serialize

On Fri, 2001-10-05 at 14:57, Dave Cramer wrote:
> While fixing the handling of "unknown" data type in the result set I
> was faced with wading through the Serialize code.
>
> I am wondering if this is really a required/desireable feature?
>
> How many people out there are actually using it?
>
> Do we need/want it?
>
> My thoughts are:
>
> 1) There are plenty of persistence layers which do this job much
> better.
>
> 2) I don't think this belongs in a driver.
> 3) The code will be simpler.

How do I do a database request via JDBC and save the result set to a
text file on the client computer? Isn't that what serialize is for? If
so I need it in the driver.(and instructions on how to get it to work
=:-b)

Cheers

Tony Grant

--
RedHat Linux on Sony Vaio C1XD/S
http://www.animaproductions.com/linux2.html
Macromedia UltraDev with PostgreSQL
http://www.animaproductions.com/ultra.html

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message David Brownlee 2001-10-05 15:06:30 date problem with postgres JDBC 7.1 driver
Previous Message Tony Grant 2001-10-05 13:33:31 Re: Serialize