Results 1 to 2 of 2

Thread: Plz help me

  1. #1
    harshil is offline Member
    Join Date
    Apr 2010
    Posts
    1
    Rep Power
    0

    Default Plz help me

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



    public class admin1 extends HttpServlet
    {

    public void doGet(HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException
    {
    String Record[] = new String[1];
    int Suc;
    String Did;
    Record[0] = req.getParameter("drname");
    PrintWriter out = res.getWriter();
    //Suc=ShowRecord(out);

    res.setContentType("text/html");
    long n = 0 ;
    if(Integer.parseInt(Record[0])<10)
    Did="D00"+Record[0];
    else
    Did="D0"+Record[0];

    try{
    String url="jdbc:odbc:hms";
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection conn=DriverManager.getConnection(url);
    Statement stmt=conn.createStatement();
    ResultSet rs;
    rs= stmt.executeQuery("SELECT * FROM Patient_Details where Doctor_Id="+Did+"");
    while(rs.next()){
    //+" "+rs.getString(3)+" "+rs.getString(4)+" "+rs.getString(5)+" "+rs.getString(6)+" "+rs.getString(7)+" "+rs.getString(8)+" "+rs.getString(9)+

    out.println( rs.getString(1)+"<br>");
    }
    }
    catch(Exception e){
    e.printStackTrace(out);
    }
    }


    }




    this is a code which i have return but i get an error
    "java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1. at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc .java:6957) at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java :7114) at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(JdbcOdbc.java :3110) at sun.jdbc.odbc.JdbcOdbcStatement.execute(JdbcOdbcSt atement.java:338) at sun.jdbc.odbc.JdbcOdbcStatement.executeQuery(JdbcO dbcStatement.java:253) at admin1.doGet(admin1.java:33) at javax.servlet.http.HttpServlet.service(HttpServlet .java:617) at javax.servlet.http.HttpServlet.service(HttpServlet .java:717) at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:206) at org.netbeans.modules.web.monitor.server.MonitorFil ter.doFilter(MonitorFilter.java:390) at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:191) at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:293) at org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:849) at org.apache.coyote.http11.Http11Protocol$Http11Conn ectionHandler.process(Http11Protocol.java:583) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run( JIoEndpoint.java:454) at java.lang.Thread.run(Thread.java:619)"

  2. #2
    PhQ's Avatar
    PhQ
    PhQ is offline Senior Member
    Join Date
    Mar 2010
    Location
    Lithuania
    Posts
    358
    Rep Power
    5

    Default

    Wrong section, can you please put your code in [ code] -- YOUR CODE -- [ /code]. (no spaces)

    On topic: Try adding a record into Patient_Details.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •