フォームからDBにデータを追加しようとすると、次のようなエラーが発生します。
例外
org.apache.jasper.JasperException:java.lang.NumberFormatException:nullルート原因
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);
}
%>
誰かがこれについて私を助けることができますか?ありがとうございました。