Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7921221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T16:30:22+00:00 2026-06-03T16:30:22+00:00

I am trying to use a data key pair in a combobox that is

  • 0

I am trying to use a data key pair in a combobox that is filled from a database. To update records in the database.
I am able to fill the combobox with data from the database, however when I go to update a record with data from the combobox I receive an error stating the I have a null pointer if the select index of the combobox is blank.
I am trying to devise a way to check if the box is blank, so that if it is I don’t use it for the update.
I am thoroughly stumped on this.

Here is the code I have so far to check for null values and run the update if the values is not null. The updates work by themselves but when I try getting data from a combobox where I have to cast the datatype and nothing is selected I receive the error.

public Boolean checkStrNull(String strTest) {
    if (strTest == null) {
        return false;
    } else if (strTest.isEmpty()) {
        return false;
    } else if (strTest == "") {
        return false;
    } else {
        return true;
    }
}

public Boolean checkIntNull(int intTest) {
    if (intTest == 0) {
        return false;
    } else {
        return true;
    }
}

public void updateIntAnimal(Animal a, String strField, Integer intNew)
        throws SQLException {
    if (checkIntNull(intNew)) {
        a.updateIntField(strField, intNew);
    }
}

public void updateStrAnimal(Animal a, String strField, String strNew)
        throws SQLException {
    if (checkStrNull(strNew)) {
        a.updateStrField(strField, strNew);
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T16:30:25+00:00Added an answer on June 3, 2026 at 4:30 pm

    You can use the getSelectedIndex() method on the combobox to see if there is a selection:

    […] Returns -1 if there is no selected item or if the user specified an item which is not in the list.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to use a jQuery selector on data I get back from
So I am trying to use jQuery to insert data from an ajax call.
I'm trying to use the OleDb CSV parser to load some data from a
I am trying to use the data I have received from a php script,
I'm trying to use LinqToEntities and just noticed that there are no foreign key
I'm trying to use an in-memory SQLite database to test my data layer which
I'm trying to use Dynamic Data with a entity model that has Abstract class
I am trying to use handle database with insert, update, and delete such as
I'm trying to use the DataAnnotationsModelBinder in order to use data annotations for server-side
I'm trying to use a data view web part (via SPD 2007) to consume

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.