You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by Dimple Bhatia <di...@gmail.com> on 2007/10/03 07:32:38 UTC

Passing in objects to Stored procedures

Hi,
I am trying to create a database side procedure(procedure will be created
when the database is created) but the input parameter needs to be an object
of some class X that I have. I tried to d that and for the arg type,I
specified "

TypeDescriptor[] arg_types = {

DataTypeDescriptor.*getSQLDataTypeDescriptor*(

"Table")

};"

Where Table is the nam eof the Java class who object I will be passing in
when calling the store dprocedure.

But when issuing the preareCall(), I get a null pointer execpetion in

TypeId typeId = TypeId.*getBuiltInTypeId*(td.getJDBCTypeId());

in resolveRoutine().

I thought we are allowed to pass in Java objects to stored procedures but
the *getBuiltInTypeId returns null* since it does include the JAVA_OBJECT
type id.

Can we create and call java store dprocedures which can take in objects of a
class?

if so, can someone help with what I maybemissing here.

Thanks

Dimple.

Re: Fwd: Passing in objects to Stored procedures

Posted by Dimple Bhatia <di...@gmail.com>.
Thanks Rick and Kathey.
Rick, thanks for your workaround of using serialization of the object. I
will try that out.


On 10/5/07, Rick Hillegas <Ri...@sun.com> wrote:
>
> Hi Dimple,
>
> In general, the arguments to functions and procedures must be legal
> Derby datatypes. Derby does not currently have a datatype for arbitrary
> Java objects. Adding object support (ADTs) to Derby is tracked by
> DERBY-651.
>
> In the short term, you could try passing your objects as Strings or byte
> arrays. The corresponding datatypes for the database procedure arguments
> would be varchar or varbinary. The client would then be responsible for
> serializing the object as a String or byte array and the actual database
> procedure code would be responsible for deserializing these forms back
> into objects.
>
> Hope this helps,
> -Rick
>
> Dimple Bhatia wrote:
> > Hello,
> > Could someone pls. help me with my question below.
> > Thanks
> > Dimple
> >
> >
> > ---------- Forwarded message ----------
> > From: *Dimple Bhatia* <dimp20@gmail.com <ma...@gmail.com>>
> > Date: Oct 2, 2007 10:32 PM
> > Subject: Passing in objects to Stored procedures
> > To: derby-dev <derby-dev@db.apache.org <ma...@db.apache.org>>
> >
> >
> > Hi,
> > I am trying to create a database side procedure(procedure will be
> > created when the database is created) but the input parameter needs to
> > be an object of some class X that I have. I tried to d that and for
> > the arg type,I specified "
> >
> > TypeDescriptor[] arg_types = {
> >
> > DataTypeDescriptor./getSQLDataTypeDescriptor/(
> >
> > "Table" )
> >
> > };"
> >
> > Where Table is the nam eof the Java class who object I will be passing
> > in when calling the store dprocedure.
> >
> > But when issuing the preareCall(), I get a null pointer execpetion in
> >
> > TypeId typeId = TypeId./getBuiltInTypeId/(td.getJDBCTypeId());
> >
> > in resolveRoutine().
> >
> > I thought we are allowed to pass in Java objects to stored procedures
> > but the /getBuiltInTypeId returns null/ since it does include the
> > JAVA_OBJECT type id.
> >
> > Can we create and call java store dprocedures which can take in
> > objects of a class?
> >
> > if so, can someone help with what I maybemissing here.
> >
> > Thanks
> >
> > Dimple.
> >
>
>

Re: Fwd: Passing in objects to Stored procedures

Posted by Rick Hillegas <Ri...@Sun.COM>.
Hi Dimple,

In general, the arguments to functions and procedures must be legal 
Derby datatypes. Derby does not currently have a datatype for arbitrary 
Java objects. Adding object support (ADTs) to Derby is tracked by DERBY-651.

In the short term, you could try passing your objects as Strings or byte 
arrays. The corresponding datatypes for the database procedure arguments 
would be varchar or varbinary. The client would then be responsible for 
serializing the object as a String or byte array and the actual database 
procedure code would be responsible for deserializing these forms back 
into objects.

Hope this helps,
-Rick

Dimple Bhatia wrote:
> Hello,
> Could someone pls. help me with my question below.
> Thanks
> Dimple
>
>
> ---------- Forwarded message ----------
> From: *Dimple Bhatia* <dimp20@gmail.com <ma...@gmail.com>>
> Date: Oct 2, 2007 10:32 PM
> Subject: Passing in objects to Stored procedures
> To: derby-dev <derby-dev@db.apache.org <ma...@db.apache.org>>
>
>  
> Hi,
> I am trying to create a database side procedure(procedure will be 
> created when the database is created) but the input parameter needs to 
> be an object of some class X that I have. I tried to d that and for 
> the arg type,I specified "
>
> TypeDescriptor[] arg_types = {
>
> DataTypeDescriptor./getSQLDataTypeDescriptor/(
>
> "Table" )
>
> };"
>
> Where Table is the nam eof the Java class who object I will be passing 
> in when calling the store dprocedure.
>
> But when issuing the preareCall(), I get a null pointer execpetion in
>
> TypeId typeId = TypeId./getBuiltInTypeId/(td.getJDBCTypeId());
>
> in resolveRoutine().
>
> I thought we are allowed to pass in Java objects to stored procedures 
> but the /getBuiltInTypeId returns null/ since it does include the 
> JAVA_OBJECT type id.
>
> Can we create and call java store dprocedures which can take in 
> objects of a class?
>
> if so, can someone help with what I maybemissing here.
>
> Thanks
>
> Dimple.
>


Fwd: Passing in objects to Stored procedures

Posted by Dimple Bhatia <di...@gmail.com>.
Hello,
Could someone pls. help me with my question below.
Thanks
Dimple


---------- Forwarded message ----------
From: Dimple Bhatia <di...@gmail.com>
Date: Oct 2, 2007 10:32 PM
Subject: Passing in objects to Stored procedures
To: derby-dev <de...@db.apache.org>


Hi,
I am trying to create a database side procedure(procedure will be created
when the database is created) but the input parameter needs to be an object
of some class X that I have. I tried to d that and for the arg type,I
specified "

TypeDescriptor[] arg_types = {

DataTypeDescriptor.*getSQLDataTypeDescriptor*(

"Table")

};"

Where Table is the nam eof the Java class who object I will be passing in
when calling the store dprocedure.

But when issuing the preareCall(), I get a null pointer execpetion in

TypeId typeId = TypeId.*getBuiltInTypeId*(td.getJDBCTypeId());

in resolveRoutine().

I thought we are allowed to pass in Java objects to stored procedures but
the *getBuiltInTypeId returns null* since it does include the JAVA_OBJECT
type id.

Can we create and call java store dprocedures which can take in objects of a
class?

if so, can someone help with what I maybemissing here.

Thanks

Dimple.

Re: Passing in objects to Stored procedures

Posted by Kathey Marsden <km...@sbcglobal.net>.
Dimple Bhatia wrote:
>
> Can we create and call java store dprocedures which can take in 
> objects of a class?
>
No Derby does not have java object support. This is filed as DERBY-651.

It is actually much more complex than "Re-enabling" support as the title 
says.
It requires implementation of SQL specification Part 13:SQL Routines and 
Types Using the Java Programming Language (SQL/JRT)

Kathey