Consider a situation where we need to delete a table from a database.
To delete a table from the database firstly we need to make a connection with the database. When the connection has been established pass a query for deleting a table inside the prepareStatement() method and it will return the PreparedStatement object. Now call the method executeUpdate() of the PreparedStatement interface which will helps us to know the status of the program.
The code of the program is given below:
XML File for this program:
Table in the database before deletion:
|mysql> select * from emp_sa
| EmpName | salary |
| zulfiqar | 15000 |
| vinod | 12000 |
2 rows in set (0.00 sec)
The output of the program is given below:
Table in the database after deletion:
|mysql> select * from emp_sal;
ERROR 1146 (42S02): Table 'zulfiqar.emp_sal' doesn't exist
Posted on: July 19, 2007 If you enjoyed this post then why not add us on Google+? Add us to your Circles