Olá.
Ultimamente minha aplicação se comporta de um jeito estranho.
Não consigo mais cadastrar telefone, CPF, celular ou qualquer outro valor do tipo inteiro.
Mostra uma excessão do tipo NumberFormat for input String ="[telefone removido]", que é para o tipo inteiro.
<form action="verificar_cadastro_clientes.jsp" method=post onsubmit="return validaForm(this);">
<table class="formulario" align=center cellspacing=2 cellpadding="5" border=0>
<tr>
<td align=right>* Nome:</td>
<td>
<input type=text name="nome" value="" autocomplete="off" maxlength=40>
</td>
<td align=right>Sexo:</td>
<td>
<input type=radio name="sexo" value="Masc" autocomplete="off" checked>Masc
<input type=radio name="sexo" value="femin" autocomplete="off">Fem
</td>
</tr>
<tr>
<td align=right>* Endereço:</td>
<td for=endereco>
<input type=text name="endereco" value="" maxlength=40 autocomplete="off">
</td>
<td align=right>* Bairro:</td>
<td><input type=text name="bairro" value="" maxlength=40 autocomplete="off"></td>
</tr>
<tr>
<td align=right>* Telefone:</td>
<td>
<input type=text name="telefone" maxlength=10 autocomplete="off"
onkeypress="return SomenteNumero(event)">
</td>
<td align=right>Celular:</td>
<td><input type=text name="celular" value="" maxlength=10 autocomplete="off"
onkeypress='return SomenteNumero(event)'></td>
</tr>
<tr>
<td align=right>* RG:</td>
<td><input type=text name="RG" value="" maxlength=12 autocomplete="off"></td>
<td align=right>* CPF:</td>
<td><input type=text name="CPF" value="" maxlength=11 autocomplete="off"
onkeypress='return SomenteNumero(event)'></td>
</tr>
<tr>
<td align=right>Login:</td>
<td><input type=text name="login" value="" maxlength=11 autocomplete="off"></td>
<td align=right>Senha:</td>
<td><input type=password name="senha" value="" maxlength=11 autocomplete="off"></td>
</tr>
<tr>
</table>
<p align=center><input type=submit value=cadastrar>
<input type=reset value="reiniciar valores">
</form>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.sql.*;" %>
<%@page import="java.text.NumberFormat" session="true"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%
String sNome = request.getParameter("nome");
String sSexo = request.getParameter("sexo");
String sEndereco = request.getParameter("endereco");
String sBairro = request.getParameter("bairro");
String sTelefone = request.getParameter("telefone");
String sCel = request.getParameter("celular");
String sRG = request.getParameter("RG");
int CPF ;
try {
CPF = Integer.parseInt(request.getParameter("CPF"));
} catch (NumberFormatException nfex3) {
out.println("Tipo de dados inválido para CPF: " + nfex3.toString());
return;
}
String sLogin = request.getParameter("login");
String sSenha = request.getParameter("senha");
%>
<%
Connection con = null;
Statement stmt = null;
try {
Class.forName("org.gjt.mm.mysql.Driver");
String url="jdbc:mysql://localhost:3306/rest_web";
String user="root";
String pass="2017";
con = DriverManager.getConnection(url, user, pass);
stmt = con.createStatement();
String sql = "INSERT INTO clientes (nome, sexo, endereco, bairro, telefone, Celular, RG, CPF, "+
"login, senha) VALUES ('"+sNome+"', '"+sSexo+"', '"+sEndereco+
"', '"+sBairro+"', '"+sTelefone+"', '"+sCel+"', '"+sRG+"', "+CPF+", '"+sLogin+"', '"+sSenha+"');";
stmt.executeUpdate(sql); // ou apenas execute, dá no mesmo.
%><script language="javascript">
alert("Cliente cadastrado com sucesso!")
top.document.location.href='cadastro_clientes.jsp';
</script>
<input type=text id=nome autocomplete="off">
<input type=radio id=masc autocomplete="off">
<input type=radio id=fem autocomplete="off">
<input type=text id=endereco autocomplete="off">
<input type=text id=bairro autocomplete="off">
<input type=text id=telefone autocomplete="off">
<input type=text id=celular autocomplete="off">
<input type=text id=rg autocomplete="off">
<input type=text id=cpf autocomplete="off">
<input type=text id=login autocomplete="off">
<input type=password id=senha autocomplete="off">
<% } catch (ClassNotFoundException cnfex) {
out.println("Driver não encontrado<br>Erro: " +cnfex.toString());
} catch (SQLException sqlex) {
out.println("Erro ao cadastrar cliente:<br>" +sqlex.toString());
} %>
Alguma ajudinha ae?
Obrigado.
