Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

error in connectivity with database

 
gaurav chhabra
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sir
i want to connect my servlet with MICROSOFT ACCESS and it is giving the error GET methord does not supported..
my code is as follows.........




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

public class connection extends HttpServlet
{
public void init(ServletConfig config) throws ServletException
{
super.init(config);
}

public void doPost(HttpServletResponse res,HttpServletRequest req) throws ServletException,IOException
{
PrintWriter out=null;
try
{
String url = "jdbc dbc:ram";
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

Connection conn = DriverManager.getConnection(url,"","");

Statement st = conn.createStatement();

String query = "insert into check values('ram',100)";

st.executeUpdate(query);

res.setContentType("text/html");
out = res.getWriter();

out.println("<html>");
out.println("<body>");
out.println("<jai shri ram>");
out.println("</body>");
out.println("</html>");

conn.close();
}
catch(Exception e)
{
out.println("there is some problem");
}

}


public void doGet(HttpServletResponse res,HttpServletRequest req)throws ServletException,IOException
{
doPost(res,req);
}



}


please tell my mistake
thank you
gaurav
 
James Carman
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You've got your parameters of your doGet() method in the wrong order. The request comes before the response. So, you're not overriding anything.
 
James Carman
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh, and you did it in your doPost() method too :-)
 
gaurav chhabra
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you for your help
 
James Carman
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No problem. Did that do the trick for you?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic