Consider a situation where we need to delete a table from a database.
Consider a situation where we need to delete a table from a database.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:
import javax.servlet.*;
|
XML File for this program:
<?xml version="1.0" encoding="ISO-8859-1"?>
|
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 |
Ads