import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class AddColumnIntoTable extends HttpServlet
{
	public void doGet(HttpServletRequest req, HttpServletResponse res)
		throws IOException, ServletException
		{
		res.setContentType("text/html");
		PrintWriter pw= res.getWriter();
		Connection con;
		Statement ps;
		try
		{
			Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
			con=DriverManager.getConnection("jdbc:odbc:dataInsert");
			ps=con.createStatement();
			int i =ps.executeUpdate("ALTER TABLE data ADD Address varchar(100)");
			if(i!=0)
			 pw.println("Column has been added successfully");
			 else
				 pw.println("Column is not added");
		try
		{
			con.close();
			ps.close();
		}
		catch(Exception e)
		{
			pw.println(e);
		}
		}
		catch(SQLException sx)
		{
			pw.println(sx);
		}
		catch(ClassNotFoundException cx)
		{
			pw.println(cx);
		}
	}
}
