Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @WebService(serviceName = "FlightWebService")
- public class FlightWebService {
- private Connection connection;
- /**
- * This is a sample web service operation
- */
- @WebMethod(operationName = "CheckAvailability")
- public String CheckAv(@WebParam(name = "numberOfPeople") int n,
- @WebParam(name = "month") int month,
- @WebParam(name = "day") int d,
- @WebParam(name = "dest") String ds,
- @WebParam(name = "from") String f
- ) {
- String message="Error";
- try {
- // Connect to database
- Class.forName("com.mysql.jdbc.Driver").newInstance();
- connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/flightHotel", "root", "root");
- PreparedStatement st = connection.prepareStatement("select * from flights where dest = ?");
- st.setString(1, ds);
- ResultSet r1 = st.executeQuery();
- if (r1.next()) {
- message="<br><p> DEST Valid ! ! ! " + "<br> destination: " + ds + "✔<br>";
- } else{
- message="NO ACCESS TO DB";
- }
- } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | SQLException se) {
- }
- return message;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement