Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package BankConnection_ws;
- import java.sql.Statement;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.ResultSet;
- import javax.jws.WebService;
- import javax.jws.WebMethod;
- import javax.jws.WebParam;
- /**
- *
- * @author lava
- */
- @WebService(serviceName = "BankConnection")
- public class BankConnection {
- /**
- * This is a sample web service operation
- */
- @WebMethod(operationName = "hello")
- public String hello(@WebParam(name = "name") String txt) {
- return "Hello " + txt + " !";
- }
- /**
- * Web service operation
- */
- @WebMethod(operationName = "loginUser")
- public boolean loginUser(@WebParam(name = "catchUsername") String catchUsername, @WebParam(name = "catchPassword") String catchPassword) {
- boolean loginFlag = false;
- Connection con = null;
- Statement st = null ;
- ResultSet rs = null;
- try {
- Class.forName("com.mysql.jdbc.Drivers");
- con = DriverManager.getConnection("jdbc:mysql://localhost:8889/clientcw?useSSL=false", "root", "root");
- st = con.createStatement();
- String query = "select * from users";
- rs = st.executeQuery(query);
- while(rs.next()) {
- if(catchUsername.equals(rs.getString("username")) && catchPassword.equals(rs.getString("password"))) {
- loginFlag = true;
- break;
- } else {
- loginFlag = false;
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- return loginFlag;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement