Re: Serialize its create method throws NullPointerException

From: Barry Lind <barry(at)xythos(dot)com>
To: "Daems, Huub" <Huub(dot)Daems(at)selektvracht(dot)nl>, pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Serialize its create method throws NullPointerException
Date: 2001-11-20 17:33:31
Message-ID: 3BFA93EB.1080809@xythos.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

There are many other frameworks out there for serializing java objects.
The code in the postgres jdbc driver isn't very good, and will likely
be removed in the next release. Depending on what you are trying to do,
I would start with the Java2 serialization code and store the result in
a bytea column.

thanks,
--Barry

Daems, Huub wrote:

> Hi,
>
> does some one has a clou how to use org.postgresql.util.Serialize to create
> a table from my class....
>
>
> package kermitserver.PL;
>
> import java.io.*;
> import java.util.*;
> import java.sql.*;
> import org.postgresql.util.Serialize;
>
>
> public class Jk implements Serializable {
>
> public int oid;
>
> public Jk() {
> }
>
> public static void main(String[] args) {
> Jk jk1 = new Jk();
> jk1.oid = 0; // just in case, only for this test
>
> try {
> Class.forName("org.postgresql.Driver");
> Connection db =
> DriverManager.getConnection("jdbc:postgresql:kermitserver", "huub",
> "secret");
>
>
> org.postgresql.util.Serialize.create((org.postgresql.Connection)db, jk1);
>
> db.close();
>
> } catch (ClassNotFoundException cnfe) {
> cnfe.printStackTrace();
> } catch (SQLException sq) {
> sq.printStackTrace();
> } catch (NullPointerException npe) {
> npe.printStatckTrace();
> }
> }
>
>
> Try to run it and it gave an NullPointerException:
>
> java.lang.NullPointerException
> at org.postgresql.jdbc2.ResultSet.getString(ResultSet.java:171))
> at org.postgresql.util.Serialize.create(Serialize.java:241)
> at org.postgresql.util.Serialize.create(Serialize.java:220)
> at kermitserver.PL.jk.main(jk.java:37)
>
> I am wondering what the ResultSet is doing.
> I am using jdk1.3.1_01 from Sun, jdbc7.1-1.2.jar on postgresql 7.1.3 on SuSe
> 7.3
>
> Would be nice if someone has an idea....
>
> greeting Huub
>
>
>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly
>
>

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Daems, Huub 2001-11-20 18:19:18 Re: Serialize its create method throws NullPointerException
Previous Message Chitta Barik 2001-11-20 16:47:52 Backed broken the connection