Created
June 18, 2018 14:53
-
-
Save datduyng/fa8fbe5c55ae90145919fca0d51628d7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * This Method delete all data currently exist in database table | |
| */ | |
| public static void deleteDatabaseTable() { | |
| String deleteT1 = "DELETE FROM `InvoiceProducts`;"; | |
| String deleteT2 = "DELETE FROM `Invoices`;"; | |
| String deleteT3 = "DELETE FROM `Refreshments`;"; | |
| String deleteT4 = "DELETE FROM `ParkingPasses`;"; | |
| String deleteT5 = "DELETE FROM `MovieTickets`;"; | |
| String deleteT6 = "DELETE FROM `SeasonPasses`;"; | |
| String deleteT7 = "DELETE FROM `Products`;"; | |
| String deleteT8 = "DELETE FROM `Customers`;"; | |
| String deleteT9 = "DELETE FROM `Emails`;"; | |
| String deleteT10 = "DELETE FROM `Persons`;"; | |
| String deleteT11 = "DELETE FROM `Addresses`;"; | |
| String deleteT12 = "DELETE FROM `StateCountries`;"; | |
| String deleteT13 = "DELETE FROM `Countries`;"; | |
| Connection conn = ConnectionFactory.getOne(); | |
| PreparedStatement ps = null; | |
| try { | |
| // delete table- execute query | |
| ps = conn.prepareStatement(deleteT1); | |
| ps.executeUpdate(); | |
| ps = conn.prepareStatement(deleteT2); | |
| ps.executeUpdate(); | |
| ps = conn.prepareStatement(deleteT3); | |
| ps.executeUpdate(); | |
| ps = conn.prepareStatement(deleteT4); | |
| ps.executeUpdate(); | |
| ps = conn.prepareStatement(deleteT5); | |
| ps.executeUpdate(); | |
| ps = conn.prepareStatement(deleteT6); | |
| ps.executeUpdate(); | |
| ps = conn.prepareStatement(deleteT7); | |
| ps.executeUpdate(); | |
| ps = conn.prepareStatement(deleteT8); | |
| ps.executeUpdate(); | |
| ps = conn.prepareStatement(deleteT9); | |
| ps.executeUpdate(); | |
| ps = conn.prepareStatement(deleteT10); | |
| ps.executeUpdate(); | |
| ps = conn.prepareStatement(deleteT11); | |
| ps.executeUpdate(); | |
| ps = conn.prepareStatement(deleteT12); | |
| ps.executeUpdate(); | |
| ps = conn.prepareStatement(deleteT13); | |
| ps.executeUpdate(); | |
| ConnectionFactory.release(conn); | |
| ps.close(); | |
| } catch (SQLException e) { | |
| // TODO Auto-generated catch block | |
| e.printStackTrace(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment