Advertisement
Guest User

Untitled

a guest
Mar 12th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. package com.WEB;
  2.  
  3. import java.sql.Connection;
  4. import java.sql.DriverManager;
  5. import java.sql.ResultSet;
  6. import java.sql.Statement;
  7. import javax.jws.WebService;
  8. import javax.jws.WebMethod;
  9. import javax.jws.WebParam;
  10.  
  11. @WebService(serviceName = "ServicioWEB")
  12. public class ServicioWEB {
  13.  
  14. @WebMethod(operationName = "hello")
  15. public String hello(@WebParam(name = "name") String txt) {
  16. return "Hello " + txt + " !";
  17. }
  18.  
  19. @WebMethod(operationName = "validacion")
  20. public Integer validacion(@WebParam(name = "usuario") String usuario, @WebParam(name = "pass") String pass) {
  21. try{
  22. Class.forName("com.mysql.jdbc.Driver");
  23. Connection cone = DriverManager.getConnection("jdbc:mysql://localhost/VETERINARIA", "root", "");
  24. String sql = "select * from usuarios where usuario = '@usu' and pass = '@pass'";
  25. sql = sql.replaceAll("@usu", usuario);
  26. sql = sql.replaceAll("@pass", pass);
  27. Statement stm = cone.createStatement();
  28. ResultSet rs = stm.executeQuery(sql);
  29. while(rs.next())
  30. {
  31. return rs.getInt("nivel");
  32. }
  33. return 0;
  34. }catch(Exception e){
  35. return 0;
  36. }
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement