From: | candreol <Christophe(dot)Andreoli(at)consol(dot)de> |
---|---|
To: | Dave(at)micro-automation(dot)net, pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: problem with serialization |
Date: | 2001-07-26 06:34:43 |
Message-ID: | 3B5FBA03.4942CC87@consol.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
Hi Dave,
The code is very small. It is just a test :
/*
* Java sample program
*/
import java.io.*;
import java.sql.*;
import org.postgresql.util.Serialize;
public class lili implements Serializable
{
String myString;
int myNumber;
public lili() throws ClassNotFoundException,
FileNotFoundException, IOException, SQLException
{
myString="theString";
myNumber=4;
}
private void testmethod(){};
public void testmethod2x(){};
public static void main(String args[])
{
try {
lili mylili = new lili();
Class.forName("org.postgresql.Driver"); // load
database interface
// connect to the database
org.postgresql.Connection conn =
(org.postgresql.Connection)DriverManager.getConnection("jdbc:postgresql://localhost:5432/onlinechess",
"postgres", "mypassword"); // works
// test of serialisation
org.postgresql.util.Serialize.create(conn, mylili); // makes
problems
} catch(Exception exc)
{
System.err.println("Exception caught.\n" + exc);
exc.printStackTrace();
}
}
}
Dave Cramer wrote:
> Chris,
>
> Can you send us your code. Or a snippet?
>
> Dave
>
>
> Hi! I am new here.
>
> I did a small test to try object serialization with the
> org.postgresql.util.Serialize class.
>
> I get the following exception when I try to use the at
> org.postgresql.util.Serialize.create Method. :
>
> java.lang.NullPointerException
> at org.postgresql.jdbc2.ResultSet.getString(ResultSet.java:148)
> at org.postgresql.util.Serialize.create(Serialize.java:241)
> at org.postgresql.util.Serialize.create(Serialize.java:220)
>
> I looked at create in Serialization.java and saw that
> the exception occurs at getString although I have no table corresponding
> to the class I want to serialize.
> if(!rs.next()){
> // String lolo=rs.getString(1);}
> }
>
> Although the resultset is empty (because the table is absent) , why
> getString has been run ?
>
> Can you help me ?
>
> Chris
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://www.postgresql.org/search.mpl
From | Date | Subject | |
---|---|---|---|
Next Message | candreol | 2001-07-26 08:02:15 | Re: problem with serialization |
Previous Message | Dave Cramer | 2001-07-25 16:12:35 | RE: problem with serialization |