I'm creating a connection to the bank in Java like this:
try{
Class.forName("org.postgresql.Driver");
Connection con = DriverManager.getConnection("jdbc:postgresql://localhost/projeto","postgres","754753");
if(request.getParameter("user") != null)
{
//caminho para chegar até a tabela no BD
Statement st = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
ResultSet rs = st.executeQuery("select * from login where log_usuario = '"+
request.getParameter("user")+"' and log_senha = '"+
request.getParameter("pass")+"'");
if(rs.next())
//response.sendRedirect("paginas/home.jsp");
else
out.println("Não Logado");
}
}
catch(ClassNotFoundException ClassError){
out.println("Driver não encontrado "+ClassError);
}
catch(SQLException SQLError){
out.println("Erro de conexão com o banco de dados");
}
I want to send to ajax for it to validate with $.ajax({});
.
Within success
I want to have 3 conditions that would be:
More or less like this:
$('form').submit(function(){
var login = $(this).serialize();
$.ajax({
url:
data:
type:
success: function(resposta){
if(resposta == 'erroempty'){
$('.msg').empty().hmtl('<p class="aviso">Informe seu usuário e senha!</p>').fadeIn('slow');
}else if(resposta == 'errosenha'){
$('.msg').empty().hmtl('<p class="erro">Erro ao logar! Dados não conferem!</p>').fadeIn('slow');
}else if(resposta == 'success'){
$('.msg').empty().hmtl('<p class="sucesso">Login efetuado, aguarde...</p>').fadeIn('slow');
}
},
beforeSend: function(){
$('.loginbox h1 img').fadeIn('fast');
},
complete: function(){
$('.loginbox h1 img').fadeOut('fast');
}
});
return false;
});
How do I get Java to pass the 3 information (errorempty, error, and success) and what would I put in url
, data
and type
?