private static void deleteData() throws FileNotFoundException, ClassNotFoundException, IOException, SQLException { System.out.println("Delete the data"); System.out.println("Please Enter the idZooAddress of respective column to delete"); int temp = s.nextInt(); query = "Delete from [dbo].[Zoo_Animals] where idZooAnimals=" + temp; ZooMain.executeQuery(query); }
private static void updateColumn() { System.out.println("Updating a Column"); System.out.println("Please Enter the idZooAddress of respective column to Update"); int temp = s.nextInt(); s.nextLine(); System.out.println( "Please Enter the Columnlabel which you want to update(it Must be Animals (or) AnimalType (or) FoodType)"); String temp_col = s.nextLine(); System.out.println("Enter your Update value"); String upd = s.nextLine(); query = "UPDATE [dbo].[Zoo_Animals] SET " + temp_col + "='" + upd + "' where idZooAnimals=" + temp; try { ZooMain.executeQuery(query); } catch (Exception e) { System.out.println("Column Doesn't exists"); } }
private static void insertData() throws FileNotFoundException, ClassNotFoundException, IOException, SQLException { System.out.println("Inserting the data"); System.out.println("Please Enter the following details"); System.out.println("1.Animals"); System.out.println("2.AnimalType"); System.out.println("3.FoodType"); ZooAddress zad = new ZooAddress(ZooMain.s.nextLine(), ZooMain.s.nextLine(), ZooMain.s.nextLine()); query = "INSERT INTO [dbo].[Zoo_Animals]([Animals],[AnimalType],[FoodType]) VALUES('" + zad.getAnimals() + "','" + zad.getAnimalType() + "','" + zad.getFoodType() + "')"; ZooMain.executeQuery(query); }