Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Getting Null value from JDBC for Double data type

T JFeb 26 2018 — edited Feb 27 2018

Hi All

I wanted to fetch two double values from JDBC if they are null I want to populate them as null in my textfield and if they are 0 I wanted to populate my text field as 0. I've tried resultSet.wasNull but even if I'm getting 0 it is setting them as null value.

This is what I've written.

resultsetPricing = stmtPricingData.executeQuery();

while(resultsetPricing.next()){

    if(pricetype.equals("Price List A")){

        priceExclVat = resultsetPricing.getDouble("PRICE_EXC_VAT");

        priceInclVat = resultsetPricing.getDouble("PRICE_INC_VAT");

        if(priceExclVat == 0){

            System.out.println("Inside if EXCL");

            if(resultsetPricing.wasNull()){

                System.out.println("Inside RESULT SET NULL EXCL");

                exclVAT3.setValue(pageContext,null);

            }

        }else if(priceExclVat != 0 || priceExclVat == 0){

            System.out.println("Inside ELSE EXCL");

            priceExclVatStr =  String.valueOf(priceExclVat).replace(".",",");

            exclVAT3.setValue(pageContext,priceExclVatStr);

        }

        if(priceInclVat==0){

            System.out.println("Inside if INCL");

            if(resultsetPricing.wasNull()){

                System.out.println("Inside RESULT SET NULL INCL");

                inclVAT3.setValue(pageContext,null);

            }

        }else if(priceInclVat!=0 || priceInclVat==0){

            System.out.println("Inside ELSE INCL");

            priceInclVatStr = String.valueOf(priceInclVat).replace(".",",");

            inclVAT3.setValue(pageContext,priceInclVatStr);

        }      

    }

}

Pleas tell me what I'm doing wrong.

TIA

This post has been answered by Zlatko Sirotic on Feb 27 2018
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 27 2018
Added on Feb 26 2018
5 comments
5,958 views