aspose file tools*
The moose likes JDBC and the fly likes How to pass Java Objects into Stored Procedure in DB2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How to pass Java Objects into Stored Procedure in DB2" Watch "How to pass Java Objects into Stored Procedure in DB2" New topic
Author

How to pass Java Objects into Stored Procedure in DB2

Christie George
Greenhorn

Joined: Aug 16, 2004
Posts: 19
Hi All,

Can you please help me with a solution of passing Java Objects into Stored Procedures in DB2.

I have a User Defined Datatype in DB2 as

CREATE TYPE EPUSER.CNTCT_ADDR_TYPE AS
(
"NAME" VARCHAR(100),

STREET VARCHAR(30),

CITY VARCHAR(30),

STATE VARCHAR(2),

ZIP VARCHAR(15)
)

CREATE TABLE EPUSER.COMP_COMP_INFO
(

COMP_ID NUMERIC(8) NOT NULL,

COMP_MBU NUMERIC(8),

COMP_COMPANY_ID VARCHAR(10) NOT NULL,

COMP_COMPANY_NAME VARCHAR(100),

COMP_START_DATE DATE,

COMP_END_DATE DATE,

COMP_AKNWLDG_TYPE CHAR(3),

COMP_BILNG_ADD CNTCT_ADDR_TYPE,

���

��.

���.



CONSTRAINT P_COMP_PK PRIMARY KEY (COMP_ID),

CONSTRAINT F_CPMP_FK_MBU FOREIGN KEY (COMP_MBU)

REFERENCES EPUSER.COMP_COMP_INFO (COMP_ID)

ON DELETE RESTRICT ON UPDATE RESTRICT

);

Inside the java class I will set the value using
callableStatement.setObject(6, clientModel.getBillingAddress());

Client Model.java
public class ClientModel implements Serializable
{
private String pkId;

private String companyId;

private String companyName;

private String startDate;

private String endDate;

private Address billingAddress;



public Address getBillingAddress() {

return billingAddress;
}
}

Address.java

public class Address implements Serializable{

private String street;

private String city;

private String state;

private String zipCode;



with getter and setter methods

}

What will be the datatype of the input parameter which receives this object in DB2? How will I insert value into the this UserDefined DataObject - CNTCT_ADDR_TYPE
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to pass Java Objects into Stored Procedure in DB2