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

  • Home
  • SEARCH
  • 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 953109
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:59:56+00:00 2026-05-15T23:59:56+00:00

I am having an update statament in my jsp. The problem is that when

  • 0

I am having an update statament in my jsp. The problem is that when I am changing the whole fields in the jsp and executed the update statament, the DB will be updated, but when I am updating a certain field, the other fields will be “” in the SQL statement. Also, I am having a problem is that I am having a miss match in the date, so what is the best format to be applied in the SQL statement in my jsp.

FOr the first problem:
HTML Code:

<select size="1" name="Nationality" class="content">
        <option selected value="<%=Nationality%>"><%=Nationality%></option>

<%

     try
     {

        ResultSet rs=null;

        Statement st1=null;

        String query = "select country_code, nationality_name from nationality_lkup ";

        st1 = conn1.createStatement();

        rs = st1.executeQuery(query);

        while(rs.next())    
    {

%>
    <option value="<%=rs.getString("country_code")%>" >
        <%=rs.getString("nationality_name")%></option>
<%
        }

    }
    catch (Exception e) {
      e.printStackTrace();
    }
%>

            </select>

and the update statament is:

String  sz_SQLUpdate = "UPDATE cir SET";
z_SQLUpdate = sz_SQLUpdate  + " , nationality ='"+Nationality+"'";

Also, how can I deal with the date format in the update statement?

  • 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-05-15T23:59:56+00:00Added an answer on May 15, 2026 at 11:59 pm

    but when I am updating a certain field, the other fields will be “” in the SQL statement.

    I am not sure if this is the complete code (the SQL shown as far would have produced a SQL syntax exception when executed), but you should at least not put a comma between SET and the first column name.

    If the SQL is actually syntactically valid, then it may simply mean that those variables are empty at the moment you access them to inline in the SQL statement. You should either prefill those variables or just leave the associated columns away from the SQL query if those don’t need to be updated.

    Also, I am having a problem is that I am having a miss match in the date, so what is the best format to be applied in the SQL statement in my jsp.

    The best approach is to not worry about the format and just set a fullworthy Java object representing a timestamp in the SQL statement using PreparedStatement#setTimestamp(). Also see this recent question.


    That said, you have two major problems in the code.

    1. Raw Java code in JSP files should be avoided. It only leads to trouble in all colors, not only for you, but also for others, now and in the future.

    2. This SQL is sensitive to SQL injection attacks and the JDBC code is prone to resource leaking.

    It’s going to be a long story to explain how to do things properly, so here are just a few links to go through carefully yourself so that you get the picture how to do things properly.

    • Beginning and intermediate JSP/Servlet tutorials
    • How to avoid Java code in JSP files
    • JSP/Servlet best practices
    • Using prepared statements in JDBC

    You should probably throw away that old fashioned JSP tutorial/book you’re currently reading.

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

Sidebar

Related Questions

Im having MSI ,for minor update ,i will be updating only build number with
I'm having a problem. I've got a file that I only want to update
I am having a binding update problem with my ComboBox. My ComboBox's ItemSource is
Am having a batch file used to update certain files. However when i try
I am having a problem when i update an entry in my postgresql database,
UPDATE: Problem located in my related question - Nokogiri performance problem I am having
Using T-SQL, I would like to execute an UPDATE statement that will SET columns
I'm trying to write an update trigger that will only update a password when
I am having a problem using PHP's PDO object to prepare an update statement
i am having a problem with access sql SELECT statement. the problem is that

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.