Posted In: DB2, Java Core, JDBC

DB2: Java Inserting data using stored procedure

Accesing and executing DB2 stored procedure using Java JDBC Inserting data into sample COUNTRY table: Table Schema: COUNTRY_CODE VARCHAR(20) COUNTRY_NAME VARCHAR(30) Crating a db2 stored procedure Java Code 

Read More

Tags:

by , on April 20th, 2018

Posted In: Database, JDBC

DB2 : Java Accessing the resultset returned from Stored Procedure

Taking sample example of Countries, we will return the list of countries from stored procedure matching the required criteria Creating Table   Inserting Sample Values:   Writing Stored Procedure:  Instead of fetching rows in a loop by the fetch statement, you can return a complete result  set to the calling client program. the stored procedure […]

Read More

Tags:

by , on April 19th, 2018

Posted In: GSON, JSON

GSON – How to parse input JSON with dynamic keys

Use Map to parse this JSON. This will work as JSON cannot have duplicate keys.

Read More

Tags:

by , on February 23rd, 2018

Posted In: GSON, JSON

GSON – How to parse input JSON with keys as JAVA reserved keyword

Use com.google.gson.annotations.SerializedName annotation to map json key with POJO field

Read More

Tags:

by , on February 23rd, 2018

Posted In: GSON, JSON

Gson – Deserialize json array to list generic type

Converting JSON array to ArrayList<generic> can be achieved using com.google.gson.reflect.TypeToken

Read More

Tags:

by , on February 22nd, 2018

Posted In: GSON, JSON

GSON – How to exclude fields during serialization/toJSON using JsonSerializer

Use com.google.gson.JsonSerializer to add only required fields Output maiingAddress is excluded

Read More

Tags: Tags:

by , on February 22nd, 2018

Posted In: GSON, JSON

GSON – How to exclude fields during serialization/toJSON

Use com.google.gson.annotations.Expose to exclude Output maiingAddress is excluded

Read More

Tags:

by , on February 22nd, 2018

Posted In: GSON, JSON

GSON – Resolving Expected BEGIN_OBJECT but was BEGIN_ARRAY exception

Code will throw following error com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 13 path $.student at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:224) To resolve either POJO or input JSON needs to be corrected

Read More

Tags:

by , on February 22nd, 2018

Posted In: GSON, JSON

GSON TypeAdapter – How to process large JSON file

I have successfully tried this code with 90K records. This is useful in following scenarios When it is impossible or undesirable to load the entire object model into memory. This is most relevant on mobile platforms where memory is limited. When it is necessary to read or write a document before it is completely available. […]

Read More

Tags: Tags:

by , on February 21st, 2018

Posted In: Micro, Service

Micro services – configuration management using CONSUL

This post shows one of the ways to create micro services architecture with enterprise level configuration services Steps 1. Start consul. (Click on consul.exe on windows) 2. Add consul-api java client library to maven 3. Add and fetch configuration parameters

Read More

Tags: Tags:

by , on February 20th, 2018