Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

error in connectivity with database

 
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 405
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
This is actually more of a JSP/Servlet issue than a JDBC problem. I believe you have the parameter order for your doGet and doPost methods backwards.

The correct method signature should be:
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Craig is correct. Interestingly, that code shouldn't even compile.

I'm going to move this to the Servlets forum.
 
Jeanne Boyarsky
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Gaurav,
Please don't post the same question in multiple forums
 
Crusading Chameleon likes the size of this ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
    Bookmark Topic Watch Topic
  • New Topic