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 7945655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T00:56:03+00:00 2026-06-04T00:56:03+00:00

I inserted one column in sql with null value from java.while retrieving back it

  • 0

I inserted one column in sql with null value from java.while retrieving back it is not working with null.i also checked with string.length().But when i printed the value in System.out. the value is showing as null (just null).when i checked it with condition it is not entering into loop.

String id ="1234"; 
            String name="pratap";
            String gender=null;
            String email=null;
String service="GOOGLE";
        log.info(id+name+gender+email) //output is 1234pratapnullnull   

String insert = "INSERT INTO oauthuser VALUES('"+id+"','"+name+"','"+gender+"','"+email+"','"+service"')";

In the retrieval

query ="Select * FROM oauthuser where id="+"'"+id+"'";
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection (dbUrl);
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(query);
  while(rs.next())
  {
 id=rs.getString(1);
 name=rs.getString(2);
 gender=rs.getString(3);
 email=rs.getString(4);
service_provider_name=rs.getString(5);
System.out.println(gender+email+name);//output is nullnullpratap

  } 

if(gender!="male" && gender!="female")
 System.out.println("it is printing");
  if(gender==null)
      System.out.println("it is not printing");
con.close();
  • 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-04T00:56:05+00:00Added an answer on June 4, 2026 at 12:56 am

    you can try "null" instead of NULL , but better to show us the code

    after your update

    remove + sign from your query like this

    String id ="1234"; 
                String name="pratap";
                String gender="null";
                String email="null";
    String service="GOOGLE";
            log.info(id+name+gender+email) //output is 1234pratapnullnull   
    
    String insert = "INSERT INTO oauthuser VALUES('"id"','"name"','"gender"','"email"','"service"')"
    

    and when you select , modify like this

    if(gender.equals("null"))
          System.out.println("it is not printing");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was wondering how could I remove one (wrongly inserted) entry/word from the ispell
Given that SQL Server does not allow modification of the logical INSERTED and DELETED
I am retrieving an image from SQL Server to display on a new page
I inserted the following code: $counter = 1; while($_POST['additional_contact1'] != '' || $_POST['additional_contact2'] !=
I inserted data in a MySQL database which includes Arabic script. While the output
I am using SSIS 2008 and am trying to update one column in my
I have a SQL Server 2005 database with several tables. One of the tables
I need to transfer a large number of rows from a SQL Server database
One of my ETL moves about 18 Million rows from one server to another
In sql server, i created a table with column id as int with identity,

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.