agora inbox for pljava-dev@postgresql.org
help / color / mirror / Atom feedSubject: [Pljava-dev] Passing custom java object to PL/Java
Date: Mon, 17 Oct 2005 23:45:05 +0200
Message-ID: <43541B61.8040400@click.cz> (raw)
In-Reply-To: <1B4E0340-B59B-4152-B6AF-3862B5EF1845@rakeshv.org>
References: <1B4E0340-B59B-4152-B6AF-3862B5EF1845@rakeshv.org>
Hi!
I don't know, if I'm right, but try to serialize object Recurrence like
this:
CLIENT SIDE:
============
class Recurrence implements Serializable //...should be enough
{
...
}
Recurrence rec = ....;
ByteArrayOutputStream baos = new ...;
ObjectOutputStream oos = new ObjectOutputStream( baos );
oos.writeObject( rec );
oos.close();
byte[] value = baos.toByteArray();
statement.setBinaryStream( i++, new
ByteArrayInputStream(value),value.length); // Try use type BLOB!
// I don't know if this is most effective methond, how to pass BLOB
argument to JDBC statement...
SERVER SIDE:
============
....
Recurrence rec = (Recurrence)new ObjectInputStream( byteArrayInputStream
).readObject();
Try it and tell us if such method works!
If it throws SerializebleException, try to pass simpler argument like
string and so on.
Regards
Petr Michalek
Rakesh Vidyadharan wrote:
> Is it possible to pass custom Java objects to PL/Java (the reverse of
> passing from PL/Java to client programs? The error I get seems to
> indicate that the custom data type I defined in the deployment
> descriptor is not recognised when I do the setType on PGobject.
>
> I tried to do so as shown in the following files:
>
> http://www.rakeshv.org/tmp/test.java - wrapper program that does the
> JDBC invocation from client code.
>
> http://www.rakeshv.org/tmp/RecurrenceTest.java - The PL/Java utility class
>
> http://www.rakeshv.org/tmp/Recurrence.java - The custom data that is
> passed from client to server.
>
> http://www.rakeshv.org/tmp/DeploymentDescriptor.ddr - The deployment
> descriptor
>
> The following is the stack trace from the program:
>
> org.postgresql.util.PSQLException: Unknown type testType.
> at org.postgresql.jdbc2.AbstractJdbc2Statement.setPGobject
> (AbstractJdbc2Statement.java:1480)
> at org.postgresql.jdbc2.AbstractJdbc2Statement.setObject
> (AbstractJdbc2Statement.java:1616)
> at org.postgresql.jdbc3.AbstractJdbc3Statement.setObject
> (AbstractJdbc3Statement.java:1436)
> at org.postgresql.jdbc2.AbstractJdbc2Statement.setObject
> (AbstractJdbc2Statement.java:1627)
> at test.main(test.java:26)
>
> Rakesh
> _______________________________________________
> Pljava-dev mailing list
> Pljava-dev at gborg.postgresql.org
> http://gborg.postgresql.org/mailman/listinfo/pljava-dev
>
>
>
view thread (4+ messages) latest in thread
Message-ID: <43541B61.8040400@click.cz>
Permalink: ../43541B61.8040400@click.cz/
Also on: postgresql.org/message-id/43541B61.8040400@click.cz
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pljava-dev@postgresql.org
Subject: Re: [Pljava-dev] Passing custom java object to PL/Java
In-Reply-To: <43541B61.8040400@click.cz>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox