Re: Serialize - Mailing list pgsql-jdbc
From | Dave Cramer |
---|---|
Subject | Re: Serialize |
Date | |
Msg-id | 001d01c14da9$219d1900$0301a8c0@inspiron Whole thread Raw |
In response to | Re: Serialize (Tony Grant <tony@animaproductions.com>) |
Responses |
Re: Serialize
|
List | 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@animaproductions.com] Sent: October 5, 2001 9:34 AM To: Dave@micro-automation.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
pgsql-jdbc by date: