-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTicketmaster.java
More file actions
620 lines (567 loc) · 21.9 KB
/
Ticketmaster.java
File metadata and controls
620 lines (567 loc) · 21.9 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
/*
* Database Management Systems
* Department of Computer Science & Engineering
* University of California - Riverside
*
* Target DBMS: 'Postgres'
*
*/
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.Statement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.io.File;
import java.io.FileReader;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.List;
import java.util.ArrayList;
/**
* This class defines a simple embedded SQL utility class that is designed to
* work with PostgreSQL JDBC drivers.
*
*/
public class Ticketmaster{
//reference to physical database connection
private Connection _connection = null;
static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
public Ticketmaster(String dbname, String dbport, String user, String passwd) throws SQLException {
System.out.print("Connecting to database...");
try{
// constructs the connection URL
String url = "jdbc:postgresql://localhost:" + dbport + "/" + dbname;
System.out.println ("Connection URL: " + url + "\n");
// obtain a physical connection
this._connection = DriverManager.getConnection(url, user, passwd);
System.out.println("Done");
}catch(Exception e){
System.err.println("Error - Unable to Connect to Database: " + e.getMessage());
System.out.println("Make sure you started postgres on this machine");
System.exit(-1);
}
}
/**
* Method to execute an update SQL statement. Update SQL instructions
* includes CREATE, INSERT, UPDATE, DELETE, and DROP.
*
* @param sql the input SQL string
* @throws java.sql.SQLException when update failed
* */
public void executeUpdate (String sql) throws SQLException {
// creates a statement object
Statement stmt = this._connection.createStatement ();
// issues the update instruction
stmt.executeUpdate (sql);
// close the instruction
stmt.close ();
}//end executeUpdate
/**
* Method to execute an input query SQL instruction (i.e. SELECT). This
* method issues the query to the DBMS and outputs the results to
* standard out.
*
* @param query the input query string
* @return the number of rows returned
* @throws java.sql.SQLException when failed to execute the query
*/
public int executeQueryAndPrintResult (String query) throws SQLException {
//creates a statement object
Statement stmt = this._connection.createStatement ();
//issues the query instruction
ResultSet rs = stmt.executeQuery (query);
/*
* obtains the metadata object for the returned result set. The metadata
* contains row and column info.
*/
ResultSetMetaData rsmd = rs.getMetaData ();
int numCol = rsmd.getColumnCount ();
int rowCount = 0;
//iterates through the result set and output them to standard out.
boolean outputHeader = true;
while (rs.next()){
if(outputHeader){
for(int i = 1; i <= numCol; i++){
System.out.print(rsmd.getColumnName(i) + "\t");
}
System.out.println();
outputHeader = false;
}
for (int i=1; i<=numCol; ++i)
System.out.print (rs.getString (i) + "\t");
System.out.println ();
++rowCount;
}//end while
stmt.close ();
return rowCount;
}
/**
* Method to execute an input query SQL instruction (i.e. SELECT). This
* method issues the query to the DBMS and returns the results as
* a list of records. Each record in turn is a list of attribute values
*
* @param query the input query string
* @return the query result as a list of records
* @throws java.sql.SQLException when failed to execute the query
*/
public List<List<String>> executeQueryAndReturnResult (String query) throws SQLException {
//creates a statement object
Statement stmt = this._connection.createStatement ();
//issues the query instruction
ResultSet rs = stmt.executeQuery (query);
/*
* obtains the metadata object for the returned result set. The metadata
* contains row and column info.
*/
ResultSetMetaData rsmd = rs.getMetaData ();
int numCol = rsmd.getColumnCount ();
int rowCount = 0;
//iterates through the result set and saves the data returned by the query.
boolean outputHeader = false;
List<List<String>> result = new ArrayList<List<String>>();
while (rs.next()){
List<String> record = new ArrayList<String>();
for (int i=1; i<=numCol; ++i)
record.add(rs.getString (i));
result.add(record);
}//end while
stmt.close ();
return result;
}//end executeQueryAndReturnResult
/**
* Method to execute an input query SQL instruction (i.e. SELECT). This
* method issues the query to the DBMS and returns the number of results
*
* @param query the input query string
* @return the number of rows returned
* @throws java.sql.SQLException when failed to execute the query
*/
public int executeQuery (String query) throws SQLException {
//creates a statement object
Statement stmt = this._connection.createStatement ();
//issues the query instruction
ResultSet rs = stmt.executeQuery (query);
int rowCount = 0;
//iterates through the result set and count nuber of results.
if(rs.next()){
rowCount++;
}//end while
stmt.close ();
return rowCount;
}
/**
* Method to fetch the last value from sequence. This
* method issues the query to the DBMS and returns the current
* value of sequence used for autogenerated keys
*
* @param sequence name of the DB sequence
* @return current value of a sequence
* @throws java.sql.SQLException when failed to execute the query
*/
public int getCurrSeqVal(String sequence) throws SQLException {
Statement stmt = this._connection.createStatement ();
ResultSet rs = stmt.executeQuery (String.format("Select currval('%s')", sequence));
if (rs.next()) return rs.getInt(1);
return -1;
}
/**
* Method to close the physical connection if it is open.
*/
public void cleanup(){
try{
if (this._connection != null){
this._connection.close ();
}//end if
}catch (SQLException e){
// ignored.
}//end try
}//end cleanup
/**
* The main execution method
*
* @param args the command line arguments this inclues the <mysql|pgsql> <login file>
*/
public static void main (String[] args) {
if (args.length != 3) {
System.err.println (
"Usage: " + "java [-classpath <classpath>] " + Ticketmaster.class.getName () +
" <dbname> <port> <user>");
return;
}//end if
Ticketmaster esql = null;
try{
System.out.println("(1)");
try {
Class.forName("org.postgresql.Driver");
}catch(Exception e){
System.out.println("Where is your PostgreSQL JDBC Driver? " + "Include in your library path!");
e.printStackTrace();
return;
}
System.out.println("(2)");
String dbname = args[0];
String dbport = args[1];
String user = args[2];
esql = new Ticketmaster (dbname, dbport, user, "");
boolean keepon = true;
while(keepon){
System.out.println("MAIN MENU");
System.out.println("---------");
System.out.println("1. Add User");
System.out.println("2. Add Booking");
System.out.println("3. Add Movie Showing for an Existing Theater");
System.out.println("4. Cancel Pending Bookings");
System.out.println("5. Change Seats Reserved for a Booking");
System.out.println("6. Remove a Payment");
System.out.println("7. Clear Cancelled Bookings");
System.out.println("8. Remove Shows on a Given Date");
System.out.println("9. List all Theaters in a Cinema Playing a Given Show");
System.out.println("10. List all Shows that Start at a Given Time and Date");
System.out.println("11. List Movie Titles Containing \"love\" Released After 2010");
System.out.println("12. List the First Name, Last Name, and Email of Users with a Pending Booking");
System.out.println("13. List the Title, Duration, Date, and Time of Shows Playing a Given Movie at a Given Cinema During a Date Range");
System.out.println("14. List the Movie Title, Show Date & Start Time, Theater Name, and Cinema Seat Number for all Bookings of a Given User");
System.out.println("15. EXIT");
/*
* FOLLOW THE SPECIFICATION IN THE PROJECT DESCRIPTION
*/
switch (readChoice()){
case 1: AddUser(esql); break;
case 2: AddBooking(esql); break;
case 3: AddMovieShowingToTheater(esql); break;
case 4: CancelPendingBookings(esql); break;
case 5: ChangeSeatsForBooking(esql); break;
case 6: RemovePayment(esql); break;
case 7: ClearCancelledBookings(esql); break;
case 8: RemoveShowsOnDate(esql); break;
case 9: ListTheatersPlayingShow(esql); break;
case 10: ListShowsStartingOnTimeAndDate(esql); break;
case 11: ListMovieTitlesContainingLoveReleasedAfter2010(esql); break;
case 12: ListUsersWithPendingBooking(esql); break;
case 13: ListMovieAndShowInfoAtCinemaInDateRange(esql); break;
case 14: ListBookingInfoForUser(esql); break;
case 15: keepon = false; break;
}
}
}catch(Exception e){
System.err.println (e.getMessage ());
}finally{
try{
if(esql != null) {
System.out.print("Disconnecting from database...");
esql.cleanup ();
System.out.println("Done\n\nBye !");
}//end if
}catch(Exception e){
// ignored.
}
}
}
public static int readChoice() {
int input;
// returns only if a correct value is given.
do {
System.out.print("Please make your choice: ");
try { // read the integer, parse it and break.
input = Integer.parseInt(in.readLine());
break;
}catch (Exception e) {
System.out.println("Your input is invalid!");
continue;
}//end try
}while (true);
return input;
}//end readChoice
public static void AddUser(Ticketmaster esql){//1
try{
System.out.printf("Email: ");
String email = in.readLine();
System.out.printf("First Name: ");
String fname = in.readLine();
System.out.printf("Last Name: ");
String lname = in.readLine();
System.out.printf("Phone #: ");
String phone = in.readLine();
System.out.printf("Password: ");
String pwd = in.readLine();
esql.executeUpdate(String.format("INSERT INTO users VALUES ('%s', '%s', '%s', '%s', '%s');", email, lname, fname, phone,"7AEE99C0E48BC90FEF4C030DD7D3A867195966D452E699F97777157"));
System.out.println("User Added Successfully");
}
catch( Exception e) {
e.printStackTrace();
}
}
public static void AddBooking(Ticketmaster esql){//2
try{
List<List<String>> result = esql.executeQueryAndReturnResult("SELECT MAX(bid) FROM Bookings");
int bid = Integer.parseInt(result.get(0).get(0))+1;
boolean flag = true;
String status;
String bdatetime;
int sid;
int seats=0;
String email=null;
System.out.println("Show ID: ");
sid = Integer.parseInt(in.readLine());
//System.out.println("Status: ");
status = "Pending";
System.out.println("DateTime: ");
bdatetime = in.readLine();
//Booking
while(flag) {
System.out.println("# Seats: ");
seats = Integer.parseInt(in.readLine());
result = esql.executeQueryAndReturnResult(String.format("SELECT seats FROM Bookings WHERE sid = %d",sid));
int count=0;
for(int i =0; i<result.size(); i++) {
count = count+Integer.parseInt(result.get(i).get(0));
}
count = count+seats;
result = esql.executeQueryAndReturnResult(String.format("SELECT T.tseats FROM Theaters T, Plays P WHERE P.sid = %d AND P.tid = T.tid", sid));
if(count < Integer.parseInt(result.get(0).get(0))) {
flag = false;
}
if(flag == true) {
System.out.println("Not enough seats available");
}
}
flag = true;
while(flag) {
System.out.println("Email: ");
email = in.readLine();
System.out.println(email);
if(esql.executeQuery(String.format("SELECT fname FROM Users WHERE email = '%s'",email))>0) {
flag = false;
} else {
System.out.println("Invalid email address");
}
}
esql.executeUpdate(String.format("INSERT INTO Bookings (bid, status, bdatetime, seats, sid, email) VALUES ('%d', '%s', '%s', '%d', '%d', '%s')", bid, status, bdatetime, seats, sid, email));
//ShowSeats
int cost=0;
System.out.println(String.format("Available seats for Show %d are: ",sid));
String tid = esql.executeQueryAndReturnResult(String.format("SELECT tid FROM Plays Where sid = '%d'", sid)).get(0).get(0);
result = esql.executeQueryAndReturnResult(String.format("SELECT C.sno FROM CinemaSeats C, ShowSeats S WHERE C.tid = '%s' AND C.csid = S.csid AND S.bid IS NULL",tid));
System.out.println(result);
if(result.size() == 0) {
return;
}
int i =0;
do {
String select;
String selection;
System.out.println("Which Seat would you like: ");
i++;
select = in.readLine();
selection = esql.executeQueryAndReturnResult(String.format("SELECT S.csid FROM CinemaSeats C, ShowSeats S WHERE C.sno = '%s' AND C.tid = '%s' AND C.csid = S.csid",select, tid)).get(0).get(0);
System.out.println(selection);
esql.executeUpdate(String.format("UPDATE ShowSeats SET bid = '%d' WHERE csid = '%s'", bid, selection));
cost = cost+Integer.parseInt(esql.executeQueryAndReturnResult(String.format("SELECT price FROM ShowSeats WHERE csid = '%s'",selection)).get(0).get(0));
} while(i<seats);
System.out.println(String.format("Total cost is: %d",cost));
//System.out.println(result.get(0));
//Payment
result = esql.executeQueryAndReturnResult("SELECT MAX(pid) FROM Payments");
int pid = Integer.parseInt(result.get(0).get(0))+1;
System.out.println("Payment Method: ");
String method = in.readLine();
System.out.println("Would you like to pay?(yes/no)");
String response = in.readLine();
int amount = cost;
int min = 10000000;
int max = 99999999;
int trid = (int)Math.random() * (max - min + 1) + min;
//Write to db
if(response.equals("yes")) {
esql.executeUpdate(String.format("UPDATE Bookings SET status = 'Paid' WHERE bid = '%d'",bid));
esql.executeUpdate(String.format("INSERT INTO Payments (pid, bid, pmethod, pdatetime, amount, trid) VALUES ('%d', '%d', '%s', '%s', '%d', '%d')", pid, bid, method, bdatetime, amount, trid));
}
}
catch(Exception e) {
e.printStackTrace();
}
}
public static void AddMovieShowingToTheater(Ticketmaster esql){//3
try{
int newMvid = Integer.parseInt(esql.executeQueryAndReturnResult("SELECT MAX(mvid) FROM movies").get(0).get(0))+ 1;
String mvid = Integer.toString(newMvid);
System.out.println("==========Movie Information==========");
System.out.printf("Title: ");
String title = in.readLine();
System.out.printf("Release Date (YYYY-MM-DD): ");
String rdate = in.readLine();
System.out.printf("Country: ");
String country = in.readLine();
System.out.printf("Description: ");
String description = in.readLine();
System.out.printf("Duration (in seconds): ");
String duration = in.readLine();
System.out.printf("Language (eg: EN, DE): ");
String lang = in.readLine();
System.out.printf("Genre: ");
String genre = in.readLine();
esql.executeUpdate(String.format("INSERT INTO movies VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s');", mvid, title, rdate, country, description, duration, lang, genre));
int newSid = Integer.parseInt(esql.executeQueryAndReturnResult("SELECT MAX(sid) FROM shows").get(0).get(0))+ 1;
String sid = Integer.toString(newSid);
System.out.println("==========Show Information==========");
System.out.printf("Date (YYYY-MM-DD): ");
String sdate = in.readLine();
System.out.printf("Start Time (HH:MM:SS): ");
String sttime = in.readLine();
System.out.printf("End Time (HH:MM:SS): ");
String edtime = in.readLine();
esql.executeUpdate(String.format("INSERT INTO shows VALUES ('%s', '%s', '%s', '%s', '%s');", sid, mvid, sdate, sttime, edtime));
System.out.println("==========Play Information==========");
System.out.printf("Theater ID: ");
String tid = in.readLine();
esql.executeUpdate(String.format("INSERT INTO plays VALUES ('%s', '%s');", sid, tid));
System.out.println("Added Movie Showing to Theater Successfully");
}
catch( Exception e) {
e.printStackTrace();
}
}
public static void CancelPendingBookings(Ticketmaster esql){//4
try{
esql.executeUpdate("UPDATE showseats ss SET bid = NULL From bookings b WHERE b.bid = ss.bid;");
esql.executeUpdate("UPDATE Bookings SET status = 'Cancelled' WHERE status = 'Pending'");
}
catch(Exception e) {
e.printStackTrace();
}
}
public static void ChangeSeatsForBooking(Ticketmaster esql) throws Exception{//5
try{
System.out.println("Enter your booking ID: ");
String bid = in.readLine();
String sid = esql.executeQueryAndReturnResult(String.format("SELECT sid FROM Bookings WHERE bid = '%s'",bid)).get(0).get(0);
System.out.println("Current Seat(s) for this booking are: ");
List<List<String>> result = esql.executeQueryAndReturnResult(String.format("SELECT csid FROM ShowSeats WHERE bid = '%s'", bid));
//System.out.println(result);
for(int i =0; i<result.size(); i++) {
System.out.println(esql.executeQueryAndReturnResult(String.format("SELECT sno FROM CinemaSeats WHERE csid = '%s'",result.get(i).get(0))).get(0).get(0));
System.out.println("Price: ");
String price = esql.executeQueryAndReturnResult(String.format("SELECT price FROM ShowSeats WHERE csid = '%s'",result.get(i).get(0))).get(0).get(0);
System.out.println(price);
System.out.println("Available Exchanges: ");
List<List<String>> posible = esql.executeQueryAndReturnResult(String.format("SELECT csid FROM ShowSeats WHERE price = '%s' AND sid = '%s' AND bid IS NULL", price, sid));
for(int j=0; j<posible.size(); j++) {
System.out.println(esql.executeQueryAndReturnResult(String.format("SELECT sno FROM CinemaSeats WHERE csid = '%s'", posible.get(i).get(0))));
}
}
}
catch(Exception e) {
e.printStackTrace();
}
}
public static void RemovePayment(Ticketmaster esql){//6
try{
System.out.println("Enter booking ID: ");
String bid = in.readLine();
esql.executeUpdate(String.format("UPDATE ShowSeats SET bid = '' WHERE bid = '%s'", bid));
esql.executeUpdate(String.format("UPDATE Bookings SET status = 'Cancelled' WHERE bid = '%s'",bid));
esql.executeUpdate(String.format("DELETE FROM Payments WHERE bid = '%s'",bid));
}
catch(Exception e) {
e.printStackTrace();
}
}
public static void ClearCancelledBookings(Ticketmaster esql){//7
try{
esql.executeUpdate("DELETE FROM Bookings WHERE status = 'Cancelled'");
}
catch(Exception e) {
e.printStackTrace();
}
}
public static void RemoveShowsOnDate(Ticketmaster esql){//8
try{
System.out.println("Which Cinema ID: ");
String cid = in.readLine();
System.out.println("What Date(#/#/##): ");
String date = in.readLine();
List<List<String>> result = esql.executeQueryAndReturnResult(String.format("SELECT S.sid FROM Shows S, Theaters T, Plays P WHERE S.sid = P.sid AND P.tid = T.tid AND T.cid = '%s' AND S.sdate = '%s'",cid, date));
System.out.println(result);
for(int i=0; i<result.size(); i++) {
esql.executeUpdate(String.format("DELETE FROM Plays WHERE sid = '%s'", result.get(i).get(0)));
esql.executeUpdate(String.format("DELETE FROM ShowSeats WHERE sid = '%s'", result.get(i).get(0)));
esql.executeUpdate(String.format("DELETE FROM Shows WHERE sid = '%s'", result.get(i).get(0)));
}
}
catch(Exception e) {
e.printStackTrace();
}
}
public static void ListTheatersPlayingShow(Ticketmaster esql){//9
//
try {
System.out.println("Which show would you like to search?");
String sid = in.readLine();
List<List<String>> result = esql.executeQueryAndReturnResult(String.format("SELECT T.tname FROM Theaters T, Plays P Where P.sid = '%s' AND T.tid = P.tid",sid));
System.out.println(result);
}
catch(Exception e) {
e.printStackTrace();
}
}
public static void ListShowsStartingOnTimeAndDate(Ticketmaster esql){//10
//
try{
System.out.printf("Date (YYYY-MM-DD): ");
String sdate = in.readLine();
System.out.printf("Start Time (HH:MM:SS): ");
String sttime = in.readLine();
esql.executeQueryAndPrintResult(String.format("SELECT * FROM shows where sdate = '%s' and sttime = '%s';", sdate, sttime));
}
catch(Exception e){
e.printStackTrace();
}
}
public static void ListMovieTitlesContainingLoveReleasedAfter2010(Ticketmaster esql){//11
//
try{
esql.executeQueryAndPrintResult("SELECT * FROM movies WHERE LOWER(title) LIKE '%love%' and rdate >= '2011-01-01';");
}
catch(Exception e){
e.printStackTrace();
}
}
public static void ListUsersWithPendingBooking(Ticketmaster esql){//12
//
try{
esql.executeQueryAndPrintResult("SELECT u.* FROM bookings b, users u WHERE b.status = 'Pending' and u.email = b.email;");
}
catch(Exception e){
e.printStackTrace();
}
}
public static void ListMovieAndShowInfoAtCinemaInDateRange(Ticketmaster esql){//13
//
try{
System.out.printf("Movie ID: ");
String mid = in.readLine();
System.out.printf("Cinema ID: ");
String cid = in.readLine();
System.out.printf("Start Date (YYYY-MM-DD): ");
String startDate = in.readLine();
System.out.printf("End Date (YYYY-MM-DD): ");
String endDate = in.readLine();
esql.executeQueryAndPrintResult(String.format("SELECT m.title, m.duration, s.sdate, s.sttime FROM movies m, shows s, cinemas c WHERE c.cid = '%s' and m.mvid = '%s' and s.sdate BETWEEN '%s' and '%s';", cid, mid, startDate, endDate));
}
catch(Exception e){
e.printStackTrace();
}
}
public static void ListBookingInfoForUser(Ticketmaster esql){//14
//
try{
System.out.printf("Email: ");
String email = in.readLine();
esql.executeQueryAndPrintResult(String.format("SELECT m.title, s.sdate, s.sttime, t.tname, cs.sno FROM bookings b, movies m, shows s, theaters t, cinemaseats cs, plays p WHERE b.email = '%s' and b.sid = s.sid and m.mvid = s.mvid and p.sid = s.sid and p.tid = t.tid and cs.tid = t.tid;", email));
}
catch(Exception e){
e.printStackTrace();
}
}
}