Advertisement
Guest User

Untitled

a guest
May 18th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.12 KB | None | 0 0
  1. // to compile this program you need to include hb15.zip
  2. // in the CLASSPATH environment variable
  3.  
  4. // We need to import the java.sql package to use JDBC
  5. import java.sql.*;
  6.  
  7. // for reading from the command line
  8. import java.io.*;
  9.  
  10. // for the login window
  11. import javax.swing.*;
  12. import java.awt.*;
  13. import java.awt.event.*;
  14.  
  15. // for Format.printf() and Parameters.add()
  16. import com.braju.format.*;
  17.  
  18.  
  19. /*
  20. * This class implements a graphical login window and a simple text
  21. * interface for interacting with the branch table
  22. */
  23. public class branch implements ActionListener
  24. {
  25. // command line reader
  26. private BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
  27.  
  28. private Connection con;
  29.  
  30. // user is allowed 3 login attempts
  31. private int loginAttempts = 0;
  32.  
  33. // components of the login window
  34. private JTextField usernameField;
  35. private JPasswordField passwordField;
  36. private JFrame mainFrame;
  37.  
  38.  
  39. /*
  40. * constructs login window and loads JDBC driver
  41. */
  42. public branch()
  43. {
  44. mainFrame = new JFrame("User Login");
  45.  
  46. JLabel usernameLabel = new JLabel("Enter username: ");
  47. JLabel passwordLabel = new JLabel("Enter password: ");
  48.  
  49. usernameField = new JTextField(10);
  50. passwordField = new JPasswordField(10);
  51. passwordField.setEchoChar('*');
  52.  
  53. JButton loginButton = new JButton("Log In");
  54.  
  55. JPanel contentPane = new JPanel();
  56. mainFrame.setContentPane(contentPane);
  57.  
  58.  
  59. // layout components using the GridBag layout manager
  60.  
  61. GridBagLayout gb = new GridBagLayout();
  62. GridBagConstraints c = new GridBagConstraints();
  63.  
  64. contentPane.setLayout(gb);
  65. contentPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
  66.  
  67. // place the username label
  68. c.gridwidth = GridBagConstraints.RELATIVE;
  69. c.insets = new Insets(10, 10, 5, 0);
  70. gb.setConstraints(usernameLabel, c);
  71. contentPane.add(usernameLabel);
  72.  
  73. // place the text field for the username
  74. c.gridwidth = GridBagConstraints.REMAINDER;
  75. c.insets = new Insets(10, 0, 5, 10);
  76. gb.setConstraints(usernameField, c);
  77. contentPane.add(usernameField);
  78.  
  79. // place password label
  80. c.gridwidth = GridBagConstraints.RELATIVE;
  81. c.insets = new Insets(0, 10, 10, 0);
  82. gb.setConstraints(passwordLabel, c);
  83. contentPane.add(passwordLabel);
  84.  
  85. // place the password field
  86. c.gridwidth = GridBagConstraints.REMAINDER;
  87. c.insets = new Insets(0, 0, 10, 10);
  88. gb.setConstraints(passwordField, c);
  89. contentPane.add(passwordField);
  90.  
  91. // place the login button
  92. c.gridwidth = GridBagConstraints.REMAINDER;
  93. c.insets = new Insets(5, 10, 10, 10);
  94. c.anchor = GridBagConstraints.CENTER;
  95. gb.setConstraints(loginButton, c);
  96. contentPane.add(loginButton);
  97.  
  98. // register password field and OK button with action event handler
  99. passwordField.addActionListener(this);
  100. loginButton.addActionListener(this);
  101.  
  102. // anonymous inner class for closing the window
  103. mainFrame.addWindowListener(new WindowAdapter()
  104. {
  105. public void windowClosing(WindowEvent e)
  106. {
  107. System.exit(0);
  108. }
  109. });
  110.  
  111. // size the window to obtain a best fit for the components
  112. mainFrame.pack();
  113.  
  114. // center the frame
  115. Dimension d = mainFrame.getToolkit().getScreenSize();
  116. Rectangle r = mainFrame.getBounds();
  117. mainFrame.setLocation( (d.width - r.width)/2, (d.height - r.height)/2 );
  118.  
  119. // make the window visible
  120. mainFrame.setVisible(true);
  121.  
  122. // place the cursor in the text field for the username
  123. usernameField.requestFocus();
  124.  
  125. try
  126. {
  127. // Load the Oracle JDBC driver
  128. DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
  129. }
  130. catch (SQLException ex)
  131. {
  132. System.out.println("Message: " + ex.getMessage());
  133. System.exit(-1);
  134. }
  135. }
  136.  
  137.  
  138. /*
  139. * connects to Oracle database named ug using user supplied username and password
  140. */
  141. private boolean connect(String username, String password)
  142. {
  143. // String connectURL = "jdbc:oracle:thin:@dbhost.ugrad.cs.ubc.ca:1521:ug";
  144. String connectURL = "jdbc:oracle:thin:@localhost:1521:ug";
  145.  
  146. try
  147. {
  148. con = DriverManager.getConnection(connectURL,username,password);
  149.  
  150. System.out.println("\nConnected to Oracle!");
  151. return true;
  152. }
  153. catch (SQLException ex)
  154. {
  155. System.out.println("Message: " + ex.getMessage());
  156. return false;
  157. }
  158. }
  159.  
  160.  
  161. /*
  162. * event handler for login window
  163. */
  164. public void actionPerformed(ActionEvent e)
  165. {
  166. if ( connect(usernameField.getText(), String.valueOf(passwordField.getPassword())) )
  167. {
  168. // if the username and password are valid,
  169. // remove the login window and display a text menu
  170. mainFrame.dispose();
  171. showMenu();
  172. }
  173. else
  174. {
  175. loginAttempts++;
  176.  
  177. if (loginAttempts >= 3)
  178. {
  179. mainFrame.dispose();
  180. System.exit(-1);
  181. }
  182. else
  183. {
  184. // clear the password
  185. passwordField.setText("");
  186. }
  187. }
  188.  
  189. }
  190.  
  191.  
  192. /*
  193. * displays simple text interface
  194. */
  195. private void showMenu()
  196. {
  197. int choice;
  198. boolean quit;
  199.  
  200. quit = false;
  201.  
  202. try
  203. {
  204. // disable auto commit mode
  205. con.setAutoCommit(false);
  206.  
  207. while (!quit)
  208. {
  209. System.out.print("\n\nPlease choose one of the following: \n");
  210. System.out.print("1. Insert Person\n");
  211. System.out.print("2. Delete Person\n");
  212. System.out.print("3. Update Person\n");
  213. System.out.print("4. showReservations\n");
  214. System.out.print("5. insertReservation\n");
  215. System.out.print("6. Quit\n>> ");
  216.  
  217. choice = Integer.parseInt(in.readLine());
  218.  
  219. System.out.println(" ");
  220.  
  221. switch(choice)
  222. {
  223. case 1: insertPerson(); break;
  224. case 2: deletePerson(); break;
  225. case 3: updatePerson(); break;
  226. case 4: showReservations(); break;
  227. case 5: insertReservation(); break;
  228. case 6: deleteFlight(); break;
  229. case 7: deleteTicket(); break;
  230. case 8: queryFlights( DepartureAirport, DeptFromDate, DeptToDate,
  231. ArrivalAirport, ArrivalFromDate, ArrivalToDate); break;
  232. case 8: quit = true;
  233. }
  234. }
  235.  
  236. con.close();
  237. in.close();
  238. System.out.println("\nGood Bye!\n\n");
  239. System.exit(0);
  240. }
  241. catch (IOException e)
  242. {
  243. System.out.println("IOException!");
  244.  
  245. try
  246. {
  247. con.close();
  248. System.exit(-1);
  249. }
  250. catch (SQLException ex)
  251. {
  252. System.out.println("Message: " + ex.getMessage());
  253. }
  254. }
  255. catch (SQLException ex)
  256. {
  257. System.out.println("Message: " + ex.getMessage());
  258. }
  259. }
  260.  
  261.  
  262. private void deleteTicket(String Ticket_ID) {
  263.  
  264. PreparedStatement psDeleteTicket;
  265. try
  266. {
  267. psDeleteTicket = con.prepareStatement("UPDATE Ticket T SET T.Cancelled="+1+"WHERE T.TicketID="+Ticket_ID);
  268. psDeleteTicket.executeUpdate();
  269. con.commit();
  270. psDeleteTicket.close();
  271. }
  272. catch (SQLException ex)
  273. {
  274. System.out.println("Message: " + ex.getMessage());
  275.  
  276. try
  277. {
  278. con.rollback();
  279. }
  280. catch (SQLException ex2)
  281. {
  282. System.out.println("Message: " + ex2.getMessage());
  283. System.exit(-1);
  284. }
  285. }
  286.  
  287. }
  288.  
  289. /*Returns the Flight_Num as a String*/
  290. private String queryFlights( String DepartureAirport, String DeptFromDate, String DeptToDate,
  291. String ArrivalAirport, String ArrivalFromDate, String ArrivalToDate,
  292. int SortByPrice, int SortBySeatsRemaining){
  293.  
  294. PreparedStatement psFlightNumber;
  295. try
  296. {
  297. //psSearchForPerson = con.prepareStatement("SELECT FROM Person WHERE )
  298. psFlightNumber = con.prepareStatement( "SELECT fd.Depart_Timestamp, fd. Airport_ID, fa.Arrive_Timestamp, fa.Airport_ID, t.ticket_price, s.IsBusinessClass"+
  299. "FROM Ticket t, TicketForSeat ts, Seat s, FlightDeparture fd, FlightArrival fa"+
  300. "WHERE t.Ticket_ID = ts.Ticket_ID " +
  301. "AND ts.Seat_No = s.Seat_No AND" +
  302. "s.Flight_No = fd.Flight_No AND " +
  303. "s.Flight_No = fa.Flight_No AND" +
  304. "fd.Airport_ID = "+"DepartureAirport"+" AND" +
  305. "fa.Airport_ID = "+"ArrivalAirport"+" AND"+
  306. "fa.Arrive_Timestamp > "+"ArriveFromDate "+"AND"+
  307. "fa.Arrive_Timestamp < "+"ArriveToDate "+"AND"+
  308. "fd.Depart_Timestamp >"+" DeptFromDate "+"AND"+
  309. "fd.Depart_Timestamp < "+"DeptToDate "+"AND"+
  310. "s.IsTaken = 0");
  311.  
  312.  
  313. psFlightNumber.executeUpdate();
  314.  
  315. con.commit();
  316. psFlightNumber.close();
  317. }
  318. catch (SQLException ex)
  319. {
  320. System.out.println("Message: " + ex.getMessage());
  321.  
  322. try
  323. {
  324. con.rollback();
  325. }
  326. catch (SQLException ex2)
  327. {
  328. System.out.println("Message: " + ex2.getMessage());
  329. System.exit(-1);
  330. }
  331. }
  332.  
  333. String FlightNum;
  334.  
  335.  
  336. return FlightNum;
  337.  
  338.  
  339. /*incomplete*/
  340. }
  341.  
  342. private void deleteFlight(int Flight_No) {
  343. PreparedStatement psDeleteFlight;
  344. PreparedStatement psUpdateTickets;
  345.  
  346.  
  347. try
  348. {
  349. //psSearchForPerson = con.prepareStatement("SELECT FROM Person WHERE )
  350. psDeleteFlight = con.prepareStatement("DELETE FROM Flight WHERE Flight_No ="+Flight_No);
  351.  
  352. psUpdateTickets = con.prepareStatement("UPDATE Ticket T SET T.Cancelled="+1+"WHERE T.TicketID= (SELECT T2.TicketID"+
  353. "FROM Ticket T2, TicketForSeat, Seat, FlightDeparture, FlightArrival"+
  354. "WHERE T2.TicketID = TicketForSeat.TicketID AND"+
  355. "TicketForSeat.Seat_No = Seat.Seat_No AND TicketForSeat.Flight_No = Seat.Flight_No AND Seat.Flight_No = FlightDeparture.Flight_No AND Seat.Flight_No = FlightArrival.Flight_No");
  356.  
  357. psDeleteFlight.executeUpdate();
  358. psUpdateTickets.executeUpdate();
  359.  
  360. con.commit();
  361. psDeleteFlight.close();
  362. psUpdateTickets.close();
  363. }
  364. catch (SQLException ex)
  365. {
  366. System.out.println("Message: " + ex.getMessage());
  367.  
  368. try
  369. {
  370. con.rollback();
  371. }
  372. catch (SQLException ex2)
  373. {
  374. System.out.println("Message: " + ex2.getMessage());
  375. System.exit(-1);
  376. }
  377. }
  378. }
  379.  
  380.  
  381. private void insertPerson(int CID, String Name, String PhoneNum, String DOB, String Password, String Email, int isAdmin)
  382. {
  383.  
  384. PreparedStatement ps;
  385.  
  386. try
  387. {
  388. ps = con.prepareStatement("INSERT INTO Person VALUES (?,?,?,?,?,?,?)");
  389.  
  390. ps.setInt(1, CID); // This must be ps.setInt
  391. ps.setString(2, Name);
  392. ps.setString(3, PhoneNum);
  393. ps.setString(4, DOB);
  394. ps.setString(5, Password);
  395. ps.setString(6, Email);
  396. ps.setInt(6, isAdmin);
  397.  
  398. ps.executeUpdate();
  399. con.commit();
  400.  
  401. ps.close();
  402. }
  403. catch (SQLException ex)
  404. {
  405. System.out.println("Message: " + ex.getMessage());
  406. try
  407. {
  408. // undo the insert
  409. con.rollback();
  410. }
  411. catch (SQLException ex2)
  412. {
  413. System.out.println("Message: " + ex2.getMessage());
  414. System.exit(-1);
  415. }
  416. }
  417. }
  418.  
  419.  
  420. private void insertReservation(int Ticket_ID, int CID, String Payment_date, int Payment_ID, int Seat_No, int Flight_No)
  421. {
  422.  
  423. PreparedStatement psNewTicketForPerson;
  424. PreparedStatement psNewPaysFor;
  425. PreparedStatement psNewTransactTicket;
  426. PreparedStatement psNewTicket;
  427. PreparedStatement psNewTicketForSeat;
  428. PreparedStatement psUpdateSeat;
  429.  
  430. try
  431. {
  432. psNewTicketForPerson = con.prepareStatement("INSERT INTO TicketForPerson VALUES (?,?)");
  433. psNewTicketForPerson.setInt(1, Ticket_ID); // int
  434. psNewTicketForPerson.setInt(2, CID); // int
  435.  
  436. psNewPaysFor = con.prepareStatement("INSERT INTO PaysFor VALUES (?,?,?)");
  437. psNewPaysFor.setString(1, Payment_date); // String
  438. psNewPaysFor.setInt(2, Payment_ID); // int
  439. psNewPaysFor.setInt(3,CID); // int
  440.  
  441. psNewTransactTicket = con.prepareStatement("INSERT INTO TransactTicket VALUES (?,?)");
  442. psNewTransactTicket.setInt(1,Ticket_ID);
  443. psNewTransactTicket.setInt(2, Payment_ID);
  444.  
  445. psNewTicket = con.prepareStatement("INSERT INTO Ticket VALUES (?)");
  446. psNewTicket.setInt(1,Ticket_ID);
  447.  
  448. psNewTicketForSeat = con.prepareStatement("INSERT INTO TicketForSeat VALUES (?,?,?)");
  449. psNewTicketForSeat.setInt(1,Ticket_ID);
  450. psNewTicketForSeat.setInt(2,Seat_No);
  451. psNewTicketForSeat.setInt(3,Flight_No);
  452.  
  453. psUpdateSeat = con.prepareStatement("UPDATE Seat S SET S.IsTaken = 1 WHERE S.Seat_No = "+Seat_No+" and S.Flight_No ="+Flight_No);
  454.  
  455. psNewTicketForPerson.executeUpdate();
  456. psNewPaysFor.executeUpdate();
  457. psNewTransactTicket.executeUpdate();
  458. psNewTicket.executeUpdate();
  459. psNewTicketForSeat.executeUpdate();
  460. psUpdateSeat.executeUpdate();
  461. // commit work
  462. con.commit();
  463.  
  464. psNewTicketForPerson.close();
  465. psNewPaysFor.close();
  466. psNewTransactTicket.close();
  467. psNewTicket.close();
  468. psNewTicketForSeat.close();
  469. psUpdateSeat.close();
  470.  
  471. }
  472. catch (SQLException ex)
  473. {
  474. System.out.println("Message: " + ex.getMessage());
  475. try
  476. {
  477. // undo the insert
  478. con.rollback();
  479.  
  480. }
  481. catch (SQLException ex2)
  482. {
  483. System.out.println("Message: " + ex2.getMessage());
  484. System.exit(-1);
  485. }
  486. }
  487. }
  488.  
  489.  
  490.  
  491.  
  492. /*
  493. * deletes a branch
  494. */
  495. private void deletePerson(String Email, String Password)
  496. {
  497.  
  498. PreparedStatement psDeletePerson;
  499.  
  500.  
  501. try
  502. {
  503. //psSearchForPerson = con.prepareStatement("SELECT FROM Person WHERE )
  504. psDeletePerson = con.prepareStatement("DELETE FROM Person WHERE Email LIKE '%" +Email + "%' and Password LIKE '%" +Password+"%'");
  505.  
  506. int rowCount = psDeletePerson.executeUpdate();
  507.  
  508. if (rowCount == 0)
  509. {
  510. System.out.println("\nPerson " + Email + " does not exist!");
  511. }
  512.  
  513. con.commit();
  514.  
  515. psDeletePerson.close();
  516. }
  517. catch (SQLException ex)
  518. {
  519. System.out.println("Message: " + ex.getMessage());
  520.  
  521. try
  522. {
  523. con.rollback();
  524. }
  525. catch (SQLException ex2)
  526. {
  527. System.out.println("Message: " + ex2.getMessage());
  528. System.exit(-1);
  529. }
  530. }
  531. }
  532.  
  533.  
  534. /*
  535. * updates the name of a branch
  536. */
  537. private void updatePerson(String Name, String OldEmail, String OldPassword, String Email, String Password, String PhoneNum, String DOB)
  538. {
  539. PreparedStatement ps;
  540. try
  541. {
  542. ps = con.prepareStatement("UPDATE Person P SET P.Name = ?, P.Email = ?, P.Password = ?, P.PhoneNum = ?, P.DOB = ? WHERE P.OldEmail = ? and P.OldPassword = ?");
  543. ps.setString(1, Name);
  544. ps.setString(2, Email);
  545. ps.setString(3, Password);
  546. ps.setString(4, PhoneNum);
  547. ps.setString(5, DOB);
  548. ps.setString(6, OldEmail);
  549. ps.setString(7, OldPassword);
  550.  
  551. con.commit();
  552.  
  553. ps.close();
  554. }
  555.  
  556. catch (SQLException ex)
  557. {
  558. System.out.println("Message: " + ex.getMessage());
  559.  
  560. try
  561. {
  562. con.rollback();
  563. }
  564. catch (SQLException ex2)
  565. {
  566. System.out.println("Message: " + ex2.getMessage());
  567. System.exit(-1);
  568. }
  569. }
  570. }
  571.  
  572.  
  573. /*
  574. * display information about branches
  575. */
  576. private void showReservations()
  577. {
  578.  
  579. String FlightDepartsFrom__TimeStamp;
  580. String FlightArrivesAt__TimeStamp;
  581. String FlightDepartsFrom__Airport_ID;
  582. String FlightArrivesAt__Airport_ID;
  583. int FlightDepartsFrom__Flight_No;
  584. int Seat__Seat_No;
  585. int Seat__IsBusinessClass;
  586. int Ticket__Ticket_ID;
  587. int PaysFor__Payment_ID;
  588. int Person__CID;
  589. String Person__Email;
  590. String Person__PhoneNum;
  591. String Person__DOB;
  592. String Person__Name;
  593.  
  594. Statement stmt;
  595. ResultSet rs;
  596.  
  597. try
  598. {
  599. stmt = con.createStatement();
  600. rs = stmt.executeQuery(
  601. "SELECT FlightDepartsFrom.TimeStamp, FlightArrivesAt.Timestamp, FlightDepartsFrom.Airport_ID, FlightArrivesAt.Airport_ID, FlightDepartsFrom.Flight_No, Seat.Seat_No, Seat.IsBusinessClass, Ticket.Ticket_ID, PaysFor.Payment_ID, Person.CID, Person.Email, Person.PhoneNum, Person.DOB, Person.Name " +
  602. "FROM Person, TicketForPerson, PaysFor, TransactTicket, Ticket, TicketForSeat, Seat, FlightDeparture, FlightArrival, Airport " +
  603. "WHERE TicketForPerson.CID = Person.CID AND " +
  604. "TicketForPerson.Ticket_ID = Ticket.Ticket_ID AND " +
  605. "PaysFor.CID = Person.CID AND " +
  606. "TransactTicket.Payment_ID = PaysFor.Payment_ID AND " +
  607. "TransactTicket.Ticket_ID = Ticket.Ticket_ID AND " +
  608. "TicketForSeat.Ticket_ID = Ticket.Ticket_ID AND " +
  609. "TicketForSeat.Seat_no = Seat.Seat_no AND " +
  610. "TicketForSeat.Flight_no = Seat.Flight_no AND " +
  611. "Seat.Flight_no = FlightDeparture.Flight_no AND " +
  612. "FlightDeparture.Tail_no = Plane.Tail_no AND " +
  613. "FlightDeparture.Airport_ID = Airport.Airport_ID AND " +
  614. "FlightArrival.Tail_no = Plane.Tail_no AND " +
  615. "FlightArrival.Airport_ID = Airport.Airport_ID");
  616.  
  617. // get info on ResultSet
  618. ResultSetMetaData rsmd = rs.getMetaData();
  619.  
  620. // get number of columns
  621. int numFlightsBooked = rsmd.getColumnCount();
  622.  
  623. Parameters p = new Parameters();
  624.  
  625. // display column names;
  626. for (int i = 0; i < numFlightsBooked; i++)
  627. {
  628. // get column name and print it
  629.  
  630. // The Format class provides the static printf() method
  631. // which behaves exactly like the printf() in
  632. // the C programming language. So for the line below
  633. // the text will be left aligned; it will also have a
  634. // minimum and maximum width of 15 characters.
  635. Format.printf("%-15.15s", p.add(rsmd.getColumnName(i+1)));
  636. }
  637.  
  638. System.out.println(" ");
  639.  
  640. while(rs.next())
  641. {
  642. // for display purposes get everything from Oracle
  643. // as a string
  644.  
  645. // simplified output formatting; truncation may occur
  646.  
  647. FlightDepartsFrom__TimeStamp = rs.getString("FlightDepartsFrom.TimeStamp");
  648. Format.printf("%-15.15s", p.add(FlightDepartsFrom__TimeStamp));
  649.  
  650. FlightArrivesAt__TimeStamp = rs.getString("FlightArrivesAt.TimeStamp");
  651. Format.printf("%-15.15s", p.add(FlightArrivesAt__TimeStamp));
  652.  
  653. FlightDepartsFrom__Airport_ID = rs.getString("FlightDepartsFrom__Airport_ID");
  654. Format.printf("%-15.15s", p.add(FlightDepartsFrom__Airport_ID));
  655.  
  656. FlightArrivesAt__Airport_ID = rs.getString("FlightArrivesAt.Airport_ID");
  657. Format.printf("%-15.15s", p.add(FlightArrivesAt__Airport_ID));
  658.  
  659. FlightDepartsFrom__Flight_No = rs.getInt("FlightDepartsFrom.Flight_No");
  660. Format.printf("%-15.15s", p.add(FlightDepartsFrom__Flight_No));
  661.  
  662. Seat__Seat_No = rs.getInt("Seat.Seat_No");
  663. Format.printf("%-15.15s", p.add(Seat__Seat_No));
  664.  
  665. Seat__IsBusinessClass = rs.getInt("Seat.IsBusinessClass");
  666. Format.printf("%-15.15s", p.add(Seat__IsBusinessClass));
  667.  
  668. Ticket__Ticket_ID = rs.getInt("Ticket.Ticket_ID");
  669. Format.printf("%-15.15s", p.add(Ticket__Ticket_ID));
  670.  
  671. PaysFor__Payment_ID = rs.getInt("PaysFor.Payment_ID");
  672. Format.printf("%-15.15s", p.add(PaysFor__Payment_ID));
  673.  
  674. Person__CID = rs.getInt("Person.CID");
  675. Format.printf("%-15.15s", p.add(Person__CID));
  676.  
  677. Person__Email = rs.getString("Person.Email");
  678. Format.printf("%-15.15s", p.add(Person__Email));
  679.  
  680. Person__PhoneNum = rs.getString("Person.PhoneNum");
  681. Format.printf("%-15.15s", p.add(Person__PhoneNum));
  682.  
  683. Person__DOB = rs.getString("Person.DOB");
  684. Format.printf("%-15.15s", p.add(Person__DOB));
  685.  
  686. Person__Name = rs.getString("Person.Name");
  687. Format.printf("%-15.15s", p.add(Person__Name));
  688.  
  689.  
  690. // close the statement;
  691. // the ResultSet will also be closed
  692. stmt.close();
  693. }
  694. }
  695. catch (SQLException ex)
  696. {
  697. System.out.println("Message: " + ex.getMessage());
  698. }
  699. }
  700.  
  701.  
  702. public static void main(String args[])
  703. {
  704. branch b = new branch();
  705. }
  706. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement