Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 1 of 1

Thread: Null value coming from Database

  1. #1
    Junior Member
    Join Date
    Mar 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Arrow Null value coming from Database

    Installed_optionsHome inopthome = (Installed_optionsHome)jndiContext.lookup("installed_optionsCFY.Installed_optionsHome");
    Enumeration installed_options = inopthome.findBySiteId(siteId);
    while (installed_options.hasMoreElements()) {
        installedOptionsObject = (Installed_options)installed_options.nextElement();
        insOpt=installedOptionsObject;
    -----The below code worked earlier
    if (installedOptionsObject.getService_options_name().equals("Self Install")) {
        OptionsName = installedOptionsObject.getService_options_name();
        instStatus = installedOptionsObject.getStatus();
        Logging.log("OptionsName " + OptionsName , Logging.DEBUG);
    }
     
    if ((installedOptionsObject.getStatus()).equals("ADD")) {
     
     
        //Update IP Count if found
        if ((installedOptionsObject.getService_options_name()).equals("Addl IPs")) {
        }


        //Update Mail Count if found
        if ((installedOptionsObject.getService_options_name()).equals("Mail")) {
    // Update Mail Count
    if (mailCount != -1) {
        Logging.log(method + "Mail Count = " + mailCount, Logging.DEBUG);
        installedOptionsObject.setQuantity(mailCount);
        mailFound = true;
    } else {
        Logging.log(method + "Mail Count not received", Logging.DEBUG);
    }

    The scenario is like when I am trying to get the value from a field in a record from the database, I am getting null value. Which is in turn causing me to create a new record with a null value in a field. Basically this code was working for about 6 years. And now there is no code change to this particular file. There is value in DB field say "Service_Options_Name" ,yet it is taking the null value and when I change the code as mentioned below, its working.

    Now the change is as follows:


                    while (installed_options.hasMoreElements()) {
                        installedOptionsObject = (Installed_options)installed_options.nextElement();
                        insOpt=installedOptionsObject;
                        if ( (new Integer(installedOptionsObject.getAccess_seq()).toString()).equals(accessSeq)) {
                            //following condition was added for IP Letter Validation
                        	String serviceOptionName="";
                        	if(installedOptionsObject.getService_options_name()!=null)
                        		serviceOptionName=installedOptionsObject.getService_options_name();
     
                            if (serviceOptionName.equals("Self Install")) {
                                OptionsName = installedOptionsObject.getService_options_name();
                                instStatus = installedOptionsObject.getStatus();
                                Logging.log("OptionsName " + OptionsName , Logging.DEBUG);
                            }
     
                            if ((installedOptionsObject.getStatus()).equals("ADD")) {
     
     
                                //Update IP Count if found
                                if (serviceOptionName.equals("Addl IPs")) {
     
                                    // Update IP Count
                                //Update Mail Count if found
                                if (serviceOptionName.equals("Mail")) {
                                    // Update Mail Count
                                    if (mailCount != -1) {
                                        Logging.log(method + "Mail Count = " + mailCount, Logging.DEBUG);
                                        installedOptionsObject.setQuantity(mailCount);
                                        mailFound = true;
                                    } else {
                                        Logging.log(method + "Mail Count not received", Logging.DEBUG);
                                    }
     
                                }

    I think the problem behind this issue is when I assign the options name from DB to another string object, it is working. Else it is not working.

    Can someone pls let me know what is wrong here?
    Attached Files Attached Files


Similar Threads

  1. JFrames not coming up?
    By scooty199 in forum AWT / Java Swing
    Replies: 13
    Last Post: October 30th, 2010, 03:54 AM
  2. Null pointers
    By Jared in forum What's Wrong With My Code?
    Replies: 13
    Last Post: October 7th, 2010, 07:40 PM
  3. Returning Null
    By Woody619 in forum What's Wrong With My Code?
    Replies: 11
    Last Post: July 22nd, 2010, 01:53 PM
  4. !=null
    By ss7 in forum Java Theory & Questions
    Replies: 11
    Last Post: October 31st, 2009, 03:48 PM
  5. Null Pointer Exception
    By MysticDeath in forum Exceptions
    Replies: 2
    Last Post: October 24th, 2009, 02:49 PM