Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to pass Java Objects into Stored Procedure in DB2

 
Christie George
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic