This week's book giveaway is in the Server-Side JavaScript and NodeJS forum.
We're giving away four copies of Micro Frontends in Action and have Michael Geers on-line!
See this thread for details.
Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

How to pass Java Objects into Stored Procedure in DB2

 
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
 
Eat that pie! EAT IT! Now read this tiny ad. READ IT!
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic