How can I correctly insert accented words in MySQL? Example: if you try to insert "John" you are recording John.
MySQL is as Collation utf8-default collation
I get the input data "name" below:
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.min.css">
<title>Cadastro</title>
</head>
.
.
.
form class="form-horizontal" action='Cadastro' method="POST">
<fieldset>
<!-- Form Name -->
<legend>Cadastro de Operador</legend>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="idNome">Nome</label>
<div class="col-md-5">
<input id="idNome" name="idNome" type="text" placeholder="Nome do operador" class="form-control input-md" required="">
</div>
</div>
.
.
.
Servlet:
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String nome = request.getParameter("idNome");
String mail = request.getParameter("idDepto");
int re = Integer.parseInt(request.getParameter("idUsuario"));
String senha = request.getParameter("idSenha");
int nivel = Integer.parseInt(request.getParameter("idAdmin"));//1=adm 2=user
System.out.println(nome);
Funcionario f = new Funcionario(re,nome);
Login l = new Login(f,senha,mail,nivel);
FuncionarioDAO fd = new FuncionarioDAO();
LoginDAO ld = new LoginDAO();
try {
fd.create(f);
ld.create(f, senha, mail, nivel);
} catch (Exception ex) {
Logger.getLogger(Cadastro.class.getName()).log(Level.SEVERE, null, ex);
}
processRequest(request, response);
}
DAO Officer:
public void create(Funcionario e)throws Exception{
//**********************
try {
java.sql.Connection conexao = getConexao();
PreparedStatement pstm = (PreparedStatement) conexao.prepareStatement("INSERT INTO funcionario(re,nome) VALUES(?,?)");
pstm.setInt(1,e.getRe());
pstm.setString(2,e.getNome());
//pstm.setString(3,e.getEsc().getNome());
pstm.execute();
pstm.close();
conexao.close();
} catch (SQLException o) {
o.printStackTrace();
}
}