import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.sql.*;

public class Creation extends HttpServlet
{
   public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException
   {
      PrintWriter out = response.getWriter();
      Connection conn = null;
      try
      {
	 //load the oracle driver
         Class.forName("oracle.jdbc.driver.OracleDriver");
         
	 //connect to the database
	 conn = DriverManager.getConnection(
                   "jdbc:oracle:thin:@localhost:1521:databasename","sqlpluslogin","sqlpluspassword");

        //create statement object 
	Statement stmt = conn.createStatement();

	//execute create table statement (create a table called Student with two columns Id and Name)
	stmt.executeUpdate("CREATE TABLE Student(Id integer,Name varchar(20), PRIMARY KEY(Id))");			 
	out.println("Table created successfully.");
      }
      catch(SQLException e)
      {
         out.println(e.getMessage());
         while((e = e.getNextException()) != null)
            out.println(e.getMessage());
      }
      catch(ClassNotFoundException e)
      {
         out.println(e.getMessage());
      }
      finally
      {
         //Clean up resources, close the connection.
         if(conn != null)
         {
            try
            {
               conn.close();
            }
            catch (Exception ignored) {}
         }
         	
      }  			
   }
}

