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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:08:31+00:00 2026-06-11T17:08:31+00:00

When I try to add the data from a form to my DB it

  • 0

When I try to add the data from a form to my DB it gives me an error as

exception

org.apache.jasper.JasperException: java.lang.NumberFormatException:
null
root cause

java.lang.NumberFormatException: null

This is my code

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.sql.*" %>
<%@page import="java.util.*"%>
<%@page import="java.io.*" %>
<%
    String firstName = request.getParameter("firstName");
    String secondName = request.getParameter("secondName");
    String gender = request.getParameter("gender");
    String address = request.getParameter("address");
    String city = request.getParameter("city");
    String country = request.getParameter("country");
    int zip = Integer.parseInt(request.getParameter("zip"));
    int mobileNo = Integer.parseInt(request.getParameter("mobileNo"));
    int homePhone = Integer.parseInt(request.getParameter("homePhone"));
    String eMail = request.getParameter("eMail");

    try {
        Class.forName("com.mysql.jdbc.Driver").newInstance();
        Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/testproject", "root", "123456");
        Statement st = null;
        PreparedStatement ps = null;
        ResultSet rs = null;

        ps = con.prepareStatement("INSERT INTO studentregform (firstName, secondName, gender, address, city, country, zip, mobile, homePhone, email) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");

        ps.setString(1, firstName);
        ps.setString(2, secondName);
        ps.setString(3, gender);
        ps.setString(4, address);
        ps.setString(5, city);
        ps.setString(6, country);
        ps.setInt(7, zip);
        ps.setInt(8, mobileNo);
        ps.setInt(9, homePhone);
        ps.setString(10, eMail);

        int result = ps.executeUpdate();




    } catch (Exception e) {
        //out.println("Data not inserted");
        throw new Error(e);
    }

%>

Can anyone help me on this? Thank you.

  • 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-11T17:08:32+00:00Added an answer on June 11, 2026 at 5:08 pm

    It would seem that one of these 3 lines is giving you the problem;

    int zip = Integer.parseInt(request.getParameter("zip"));
    int mobileNo = Integer.parseInt(request.getParameter("mobileNo"));
    int homePhone = Integer.parseInt(request.getParameter("homePhone"));
    

    Are you sure they’re all entirely numeric? In case one of them is empty, null, unset or has any kind of separators like 1-800-123-4567, it can’t be stored as a number and Integer.ParseInt() will throw a NumberFormatException.

    Edit: You say that your phone numbers are 10 digits and entirely numeric. Still, you’re going to have problems since a Java Integer doesn’t have that much precision. In fact, it cannot store any number larger than about 2 billion.

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

Sidebar

Related Questions

When I try to add struct in two-dimensional array cin>>array[1][items.stoka_ime]; in error list write
Getting this error when try to add an item to my repositories/context: Collection has
I'm trying to send a lot of data from a form using the $.post
I try to build a very simple website where one can add data into
I try to binding data from window grid that show by trigger field click.
I'm practicing form validation with JavaScript but when I try to retrieve the data
I am facing some problems with JFreeChart with Java. I am retriving data from
I'm trying to insert data from a form to my database and it is
I'm making this activity that accepts data for a form from an xml and
i try to add facebook like button on my root domain that will like

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.