Advertisement
Guest User

Untitled

a guest
Jul 3rd, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.74 KB | None | 0 0
  1. try
  2. {
  3. Class.forName("org.postgresql.Driver");
  4.  
  5. Connection con=DriverManager.getConnection("JDBC:postgresql://localhost/aula_neri","admin","123456");
  6.  
  7.  
  8. Statement st = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
  9. ResultSet.CONCUR_READ_ONLY);
  10.     ResultSet rs = st.executeQuery("select * from login where log_usuario = '"+
  11.                 request.getParameter("usuario")+"' and log_senha = '"+
  12.                 request.getParameter("senha")+"'");
  13.                
  14. if(rs.next())
  15. response.sendRedirect("index.jsp");
  16.  
  17. else
  18. out.println("Negado!");            
  19.  
  20.  
  21.            
  22. }
  23. catch(ClassNotFoundException erroClass)
  24. {
  25. out.println("Classe Driver JDBC não localicado:"+erroClass);
  26. }
  27. catch(SQLException erroSql)
  28. {
  29. out.print("Erro de conexão com ao banco de dados"+erroSql);
  30. }
  31.  
  32. //David
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement