import java.io.IOException;
import java.sql.*;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.*;

public class MinutesServlet extends HttpServlet
{

    public MinutesServlet()
    {
        con = null;
        pst = null;
    }

    public void service(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse)
        throws ServletException, IOException
    {
        httpservletresponse.setContentType("text/plain");
        ServletOutputStream servletoutputstream = httpservletresponse.getOutputStream();
        servletoutputstream.println("Before Try");
        try
        {
            servletoutputstream.println("In Try");
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            con = DriverManager.getConnection("Jdbc:Odbc:JDSN", "scott", "tiger");
            servletoutputstream.println("Connected!!!");
        }
        catch(Exception exception)
        {
            servletoutputstream.println(exception.toString());
        }
        servletoutputstream.println("After Try");
        String s = httpservletrequest.getParameter("TYPE");
        if(s.equalsIgnoreCase("INSERT"))
            try
            {
                pst = con.prepareStatement("INSERT INTO MINUTES VALUES(?,?,?,?,?)");
                pst.setInt(1, Integer.parseInt(httpservletrequest.getParameter("TMeetingId")));
                pst.setString(2, httpservletrequest.getParameter("TMinutes"));
                pst.setString(3, httpservletrequest.getParameter("TN_Name"));
                pst.setString(4, httpservletrequest.getParameter("TSt_Time"));
                pst.setString(5, httpservletrequest.getParameter("TEnd_Time"));
                pst.execute();
                con.commit();
                con.close();
                servletoutputstream.println("Record Inserted:");
            }
            catch(Exception exception1)
            {
                servletoutputstream.println(exception1.toString());
            }
        else
        if(s.equalsIgnoreCase("MODIFY"))
            try
            {
                pst = con.prepareStatement("Update MINUTES SET(Minutes=?,N_Name=?,St_Time=?,End_Time=? where MeetingId=?)");
                pst.setInt(5, Integer.parseInt(httpservletrequest.getParameter("TMeetingId")));
                pst.setString(1, httpservletrequest.getParameter("TMinutes"));
                pst.setString(2, httpservletrequest.getParameter("TN_Name"));
                pst.setString(3, httpservletrequest.getParameter("TSt_Time"));
                pst.setString(4, httpservletrequest.getParameter("TEnd_Time"));
                pst.execute();
                con.commit();
                con.close();
                servletoutputstream.println("Record Updated:");
            }
            catch(Exception exception2)
            {
                servletoutputstream.println(exception2.toString());
            }
        else
        if(!s.equalsIgnoreCase("DELETE"))
            if(!s.equalsIgnoreCase("FIND"));
    }

    Connection con;
    PreparedStatement pst;
}