Advertisement
Guest User

Untitled

a guest
Mar 7th, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. @WebService(serviceName = "FlightWebService")
  2. public class FlightWebService {
  3.  
  4. private Connection connection;
  5.  
  6. /**
  7. * This is a sample web service operation
  8. */
  9.  
  10.  
  11. @WebMethod(operationName = "CheckAvailability")
  12. public String CheckAv(@WebParam(name = "numberOfPeople") int n,
  13. @WebParam(name = "month") int month,
  14. @WebParam(name = "day") int d,
  15. @WebParam(name = "dest") String ds,
  16. @WebParam(name = "from") String f
  17. ) {
  18. String message="Error";
  19.  
  20. try {
  21. // Connect to database
  22. Class.forName("com.mysql.jdbc.Driver").newInstance();
  23.  
  24. connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/flightHotel", "root", "root");
  25.  
  26. PreparedStatement st = connection.prepareStatement("select * from flights where dest = ?");
  27. st.setString(1, ds);
  28. ResultSet r1 = st.executeQuery();
  29. if (r1.next()) {
  30. message="<br><p> DEST Valid ! ! ! " + "<br> destination: " + ds + "&#10004;<br>";
  31. } else{
  32. message="NO ACCESS TO DB";
  33. }
  34. } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | SQLException se) {
  35. }
  36.  
  37. return message;
  38.  
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement