import java.io.IOException;
import java.io.PrintWriter;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class MysqlDropIndexServlet extends HttpServlet
{
	public void doGet(HttpServletRequest req, HttpServletResponse res)
		throws IOException, ServletException
	{
		res.setContentType("text/html");
		PrintWriter pw = res.getWriter();
		String driver = "com.mysql.jdbc.Driver";
		String url = "jdbc:mysql://192.168.10.13/data";
		String uid = "root";
		String psw = "root";
		String sql = "ALTER TABLE employee DROP INDEX index_1";
		try
		{
			Class.forName(driver);
			Connection con = DriverManager.getConnection(url,uid,psw);
			PreparedStatement ps = con.prepareStatement(sql);
			int i = ps.executeUpdate();
			pw.println(i +" row(s) affected <br>");
			pw.println("Index has been removed successfully");
		}
		catch(SQLException sx)
		{
			pw.println(sx);
		}
		catch(ClassNotFoundException cx)
		{
			pw.println(cx);
		}
	}
}
