-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheckTicketAJAX.jsp
More file actions
30 lines (30 loc) · 859 Bytes
/
checkTicketAJAX.jsp
File metadata and controls
30 lines (30 loc) · 859 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<%@page import="java.sql.*"%>
<%
String ticketNo = request.getParameter("ticketNo");
try
{
Integer.parseInt(ticketNo);
}
catch(Exception e){out.print(-1);}
Connection con = null;
Statement st = null;
ResultSet rs = null;
try
{
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/shivajiroadways", "root", "1234");
st = con.createStatement();
String query = "select timestampdiff(HOUR ,bookingTime, current_timestamp()) as remainValidity from ticket where ticketNo = " + ticketNo;
rs = st.executeQuery(query);
if(rs.next())
{
out.print(rs.getString("remainValidity"));
}
else
{
out.print(-1);
}
}
catch(Exception e)
{e.getMessage();}
%>