Advertisement
Guest User

Untitled

a guest
Apr 5th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package BankConnection_ws;
  7.  
  8. import java.sql.Statement;
  9. import java.sql.Connection;
  10. import java.sql.DriverManager;
  11. import java.sql.ResultSet;
  12. import javax.jws.WebService;
  13. import javax.jws.WebMethod;
  14. import javax.jws.WebParam;
  15.  
  16. /**
  17. *
  18. * @author lava
  19. */
  20. @WebService(serviceName = "BankConnection")
  21. public class BankConnection {
  22.  
  23. /**
  24. * This is a sample web service operation
  25. */
  26. @WebMethod(operationName = "hello")
  27. public String hello(@WebParam(name = "name") String txt) {
  28. return "Hello " + txt + " !";
  29. }
  30.  
  31. /**
  32. * Web service operation
  33. */
  34. @WebMethod(operationName = "loginUser")
  35. public boolean loginUser(@WebParam(name = "catchUsername") String catchUsername, @WebParam(name = "catchPassword") String catchPassword) {
  36.  
  37. boolean loginFlag = false;
  38.  
  39. Connection con = null;
  40. Statement st = null ;
  41. ResultSet rs = null;
  42.  
  43. try {
  44. Class.forName("com.mysql.jdbc.Drivers");
  45. con = DriverManager.getConnection("jdbc:mysql://localhost:8889/clientcw?useSSL=false", "root", "root");
  46. st = con.createStatement();
  47.  
  48. String query = "select * from users";
  49. rs = st.executeQuery(query);
  50.  
  51. while(rs.next()) {
  52. if(catchUsername.equals(rs.getString("username")) && catchPassword.equals(rs.getString("password"))) {
  53. loginFlag = true;
  54. break;
  55. } else {
  56. loginFlag = false;
  57. }
  58. }
  59. } catch (Exception e) {
  60. e.printStackTrace();
  61. }
  62.  
  63. return loginFlag;
  64.  
  65. }
  66.  
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement