Hi all,
I am trying to insert data from a jsp form into a table when the user clicks the submit button. I am encountering this exception.
java.lang.NumberFormatException: For input string: "type"
Here is my code:
This is the code in the form jsp:
<select name="utype">
<% try
{
while(rs2.next())
{
int type=(rs2.getInt(1));
String strName1=rs2.getString(2);
%>
<option value="type">
<%= strName1 %>
</option>
<%
}
}
catch(Exception e)
{
out.println(e);
}
%>
</select>
this is my code in the sign - up bean:
db.connect();
String firstName, lastName, address, city, state, email,userName, password, secAnswer;
int zipcode, phoneNo, utype, squestion;
firstName = request.getParameter( "firstName");
lastName = request.getParameter( "lastName");
address = request.getParameter( "address");
city = request.getParameter( "city");
state = request.getParameter( "state");
zipcode = Integer.parseInt(request.getParameter( "zipcode"));
email = request.getParameter( "email");
phoneNo = Integer.parseInt(request.getParameter( "phoneNo"));
userName = request.getParameter( "userName");
password = request.getParameter( "password");
utype = Integer.parseInt(request.getParameter( "utype"));
squestion = Integer.parseInt(request.getParameter( "squestion"));
secAnswer = request.getParameter( "secAnswer");
db.insert(firstName, lastName, address, city, state, zipcode, email, phoneNo, userName, password, utype, squestion, secAnswer);
response.sendRedirect("signupthanks.html");
and this is my dbBean's insert method:
public void insert(String firstName, String lastName, String address, String city, String state, int zipcode, String email, int phoneNo, String userName, String password,int utype, int squestion, String secAnswer) throws SQLException {
try {
PreparedStatement pstmt = null;
String queryString =
"INSERT INTO UserAccountDetails1(username,firstname, lastname, address, city, statecode, zipcode, email, phonenumber, password, usertypecode, questioncode, answer, lastmodifieduser, lastmodifiedtime) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
pstmt = dbCon.prepareStatement(queryString);
pstmt.setString(1, userName);
pstmt.setString(2, firstName);
pstmt.setString(3, lastName);
pstmt.setString(4, address);
pstmt.setString(5, city);
pstmt.setString(6, state);
pstmt.setInt(7, zipcode);
pstmt.setString(8, email);
pstmt.setInt(9, phoneNo);
pstmt.setString(10, password);
pstmt.setInt(11, utype);
pstmt.setInt(12, squestion);
pstmt.setString(13, secAnswer);
pstmt.executeUpdate();
pstmt.close();
} catch (SQLException sqlex) {
sqlex.printStackTrace();
}
}
thank you very much. any help is greatly appreciated