Try to retrieve data from database got error message

Try to retrieve data from database got error message *"java.lang.ArrayIndexOutOfBoundsException: 2*
*     sun.jdbc.odbc.JdbcOdbcPreparedStatement.clearParameter(JdbcOdbcPreparedStatement.java:1023)*
*     sun.jdbc.odbc.JdbcOdbcPreparedStatement.setDate(JdbcOdbcPreparedStatement.java:811)*
*     guestbk.doGet(guestbk.java:32)*
*     guestbk.doPost(guestbk.java:73)*
*     javax.servlet.http.HttpServlet.service(HttpServlet.java:710)*
*     javax.servlet.http.HttpServlet.service(HttpServlet.java:803)"*
I have used prepared statment
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("dd/MM/yy");
            java.util.Date dt = sdf.parse(str3);
                   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                   con=DriverManager.getConnection("jdbc:odbc:gbook");
                   //Statement stmt=con.createStatement();
PreparedStatement ps = con.prepareStatement("SELECT * from gbook where emailid =? AND date =?");
ps.setString(1,str1);
ps.setString(2,str2);
ps.setDate(3,new java.sql.Date(dt.getTime()));
//ps.executeQuery();
                   //ResultSet rs=stmt.executeQuery("select * from gbook where emailid = str1");
              ResultSet rs = ps.executeQuery();
                   out.println("<Html>");
                out.println("<Head>");
                   out.println("<Title>GuestBook</Title>");
                   out.println("</Head>");
                   out.println("<Table border=1 align=center >");
                   out.println("<H4><B><center>Teacher's Lesson Plan</center></B></H4><BR>");
                   out.println("<TR><TD><b>Teacher Name</b></TD><TD><b>Class</b></TD></TR>");
           while(rs.next())
                    ctr++;
                    String email=rs.getString("emailid");
                    String cmt=rs.getString("comment");
                    out.println("<TR><TD>"+email+"</TD><TD>"+cmt+"</TD></TR>");
        }Please anybody help .

PreparedStatement ps = con.prepareStatement("SELECT * from gbook where emailid =? AND date =?");
ps.setString(1,str1);
ps.setString(2,str2);
ps.setDate(3,new java.sql.Date(dt.getTime()));Your SQL query has 2 placeholders but you try to set 3 values.
And didn't you read the stack trace?
guestbk.doGet(guestbk.java:32)You could've tracked down line 32 and seen what was there at that line.
People on the forum help others voluntarily, it's not their job.
Help them help you.
Learn how to ask questions first: http://www.catb.org/~esr/faqs/smart-questions.html
----------------------------------------------------------------

Similar Messages

  • Error:Failed to retrieve data from database [Vendor Code:3001]

    Hello FOlks am trying to run a crystal report but when i try to run it somehow returns this error i.e [Error:Failed to retrieve data from database [Vendor Code:3001], I have no clue wats happening with this.Can anybody please throw some light on this.Am providing the sql behind this report for reference.
    SELECT "CLIENT"."CLIENT_NAME",
            "RECOVERY"."AMOUNT",
            "RECOVERY"."RECOVERY_TRANSACTION_INTERNAL",
            "RECOVERY"."ALLOCATION_CHECK_AMOUNT",
            "RECOVERY"."RECOVERY_DATE"
       FROM "HRI1_OWNER"."CLIENT""CLIENT",
            "HRI1_OWNER"."EVENT_CASE""EVENT_CASE",
            "HRI1_OWNER"."SETTLEMENT""SETTLEMENT",
            "HRI1_OWNER"."RECOVERY""RECOVERY"
      WHERE "CLIENT"."CLIENT_ID" = "EVENT_CASE"."CLIENT_ID"
        AND "EVENT_CASE"."EVENT_CASE_ID" = "SETTLEMENT"."EVENT_CASE_ID"
        AND "SETTLEMENT"."SETTLEMENT_ID" = "RECOVERY"."SETTLEMENT_ID"
        AND "CLIENT"."CLIENT_CODE" <> 'CLIENT  1'
        AND "CLIENT"."MAJOR_CLIENT_ID" in
            (Select major_client_id
               from major_client
              where major_client_code in ('LA', 'PFG'))
      ORDER BY "CLIENT"."CLIENT_NAME"Edited by: user11961230 on Nov 12, 2009 6:57 AM

    @oradba:Hi Thanks for getting bak. Well i have ran the query using PL/SQL Developer tool and yes its mapping to ORA-03001:unimplemented feature. i dont know what the problem is.
    @centinul: well i dont have any views in there.but still cudnt figure out why its throwing tht error
    Thanks
    Edited by: user11961230 on Nov 12, 2009 7:12 AM

  • Failed to retrieve data from database?

    I am a new user
    When I try to Preview a document I am prompted to enter in database information.
    I have tried a few times to connect to my server and
    continuously keep getting the same error page
    No matter what I enter in the two fields, this is what pops up.
    "Failed to retrieve data from database"
    " Details: ADO Error Code:0x
    Source: Microsoft OLE DB Provider SQL server
    Description: Invalid object name: ScratchWO.dbo.tblsyslistviewprint'.
    SQL State:42502
    Code:208"
    When the OLE DB(ADO) page opens and asks for a server and a database, what is needed to stop the error from happening
    If anyone has any information that would be great !

    SQL State:42502 means an user authorization error.  Check the user and it's access to the target database.

  • Retrieving Data from database to combobox

    Hi
    Can anyone help in retrieving data from database to combobox..
    All the names of employees and their designations are stored in database.so i want retrieve them in other page.
    both designation and names of employees are comboboxes.
    after loading tha page i need to get all the designations which are stored in database in first combobox and when i select a particular designation i need get all tha names of employees of that designation in other combobox.this has to be done using jsp and ajax.
    please can anyone give me the code for this using Ajax and Jsp.

    Hello Friend try this code
    dbdata.jsp
    <%@page language="java" import="java.sql.*"%>
    <html>
    <%
    Class.forName("..........");
    Connection n=DriverManager.getConnection ("....","...","...");
    Statement st=con.createStatement();
    ResultSet rs=st.executeQuery("select ename from emp");
    %>
    <body>
    <form>
    <select>
    <%
    while(rs.next())
    %>
    <option><%=rs.getString("ename")%></option>
    <%
    %>
    </select>
    </form>
    </body>
    </html>

  • Oracle form: how to retrieve data from database to pop list

    I have problem in retrieving data from database to item list in
    oracle forms.
    Can anyone help me.
    thanks.

    The next is an example but you can find this information in
    Forms Help:
    DECLARE
         G_DESCS RECORDGROUP;
         ERRCODE NUMBER;
         rg_id RECORDGROUP;
         rg_name VARCHAR2(40) := 'Descripciones';
    BEGIN
         rg_id := FIND_GROUP(rg_name);
         IF Id_Null(rg_id) THEN
         G_DESCS := Create_Group_From_Query (rg_name, 'SELECT
    DESCRIPCION DESCRIPCION, DESCRIPCION DESC2 FROM FORMAS_PAGO);
         ERRCODE := POPULATE_GROUP(G_DESCS);
         POPULATE_LIST('FORMAS_PAGO.CMBDESCRIPCION',G_DESCS);
         END IF;
    END;
    Saludos.
    Mauricio.

  • How to retrieve data from database to the structure(complicated)

    Hello everyone:
           I want to retrieve data from database to the structure. but the structure defined like this below:
    TOLERANZOB LIKE QAMV-TOLERANZOB
    TOLERANZOB1 LIKE QAMV-TOLERANZOB
    so how can I retrieve the data from the database ? make sure that the two fields contain data both.
    Thanks in advance .
    Regards
    Nick

    Hi Nick,
    To retreive data for TOLERANZOB from QAMV,
    If you know the key fields then use
    SELECT SINGLE TOLERANZOB FROM QAMV INTO TOLERANZOB WHERE keyfields.
    else, you can use
    SELECT TOLERANZOB FROM QAMV UPTO ONE ROWS INTO TOLERANZOB WHERE....
    Once you retreive the data using the select query, you can check if it is initial and if not move the data from TOLERANZOB to TOLERANZOB1.
    <b>Reward points for helpful answers.</b>
    Best Regards,
    Ram.

  • Error message-retrieve data from database

    I tried to retrieve data from oracle database. I got the following error message. I did compile the files without error. but when I run index.jsp I got the following error message. is it related with taglib Directives ?
    HTTP Status 500 -
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    org.apache.jasper.JasperException: Exception in JSP: /index.jsp:8
    5: <% AccessDB accessDB=new AccessDB(); %>
    6:
    7: <%-- create an instance of List, then retrieve SubjectNames --%>
    8: <% List subjNames=accessDB.getSubjectName(); %>
    9:
    10: <%-- make list accessible to page --%>
    11: <% request.setAttribute("subjNames", subjNames); %>
    Stacktrace:
         org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:504)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)
    root cause
    java.lang.NullPointerException
         org.AccessDB.getSubjectName(AccessDB.java:68)
         org.apache.jsp.index_jsp._jspService(index_jsp.java:62)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)
    note The full stack trace of the root cause is available in the Apache Tomcat/5.5.17 logs.
    Apache Tomcat/5.5.17

    Hi,
    Try to print the value in List...n comment the request.setAttribute...n then run the program....
    check wot value is printed in List....
    This error may b because the List doesnt have anyvalue into it.....

  • Error retrieving data from database

    my problem is i cant connect my eclipse to database
    it display this error
    Error parsing data org.json.JSONException: Value <html><body><h2>Checking of type java.lang.String cannot be converted to JSONObject
    my apps can run correctly before...but last night i cant open it when want to retrieve any data from database
    can somebody help me?

    This doesn't seem to have anything to do with Eclipse, but I'd guess that a server-side error message is being returned a HTML rather than the JSON you expect.

  • Failed to retrieve data from database - DataDirect Paradox

    Crystal Reports 12.1.0.892
    Windows XP SP3
    DataDirect ODBC Driver for Paradox 5.30.00.23
    Paradox 5 database
    When I run the following query against two tables:
    SELECT `Ticket1a`.`PatronID`, `PHONELIN`.`PhoneNumber`
    FROM   `PHONELIN` `PHONELIN` INNER JOIN `Ticket1a` `Ticket1a` ON `PHONELIN`.`PatronID`=`Ticket1a`.`PatronID`
    I get the following error:
    Failed to retrieve data from the database
    Details: 42000: DataDirect ODBC Paradox driver    Extra characters at end of query:  INNER.  Database VendorCode: 3902
    The SQL tracing log can be found at http://188.grandtheater.org/sql.log
    Can anyone tell me what is going on here and how I can get around it?
    TIA

    I tried the Add Command option and entered the SQL query as follows:
    select ticket1a.patronid, phonelin.phonenumber
    from ticket1a ticket1a inner join phonelin phonelin on ticket1a.patronid=phonelin.patronid
    and still got the same error as before.  Using the following SQL query:
    select ticket1a.patronid, phonelin.phonenumber
    from ticket1a, phonelin
    where ticket1a.patronid = phonelin.patronid
    I was able to get results using the DataDirect driver.
    If I use the Microsoft Paradox driver (which is very slow.  15 minutes to run this query) and use the following SQL query:
    select ticket1a.patronid, phonelin.phonenumber
    from ticket1a ticket1a inner join phonelin phonelin on ticket1a.patronid=phonelin.patronid
    I will not get the error and I will get results.
    Any reasons why the DataDirect driver is producing errors?

  • Retrieving data from database into tabular layout item

    Hi..
    If the number of product_id is 1; I can retrieve data from the database into tabular layout item.However, if the number of product_id is more than 1 error message is shown.
    Here is my code:
    select product_id
    into : PRODUCTS. ID --Tabular layout item
    from products
    where customer_id=5;
    Any suggestions????

    It's simpler to do so:
    insert that code in a post-query trigger at block level (block where is multi-item)
    You will see after execute-query, your item will be populated.
    I wrote post-query trigger no post-quert
    Message was edited by:
    RV

  • How to Retrieve data from database into another form ?

    Good Day!
    Am currently new at JSP. I've been studying it for awhile and still getting the hang of it. We are working on a project.
    Editing a given data. We have to retrieve the given data and post it to another form "Editing form".
    Since we can retrieve data using JSP but how are we going to post it to another form? I mean how are we going to transfer data from one form to another?
    Can anyone help me with codes please..

    The client is a web browser.
    The client submits a request (click a link, visit a form)
    The server gets to respond to this
    - look at request parameters from the client
    - access database
    - produce resulting html page
    - send page back to client.
    The standard pattern is to retrieve data from the database in java code, and then load that data into a bean.
    You then make that bean available as an attribute
    It is then available for use in your JSP - either <jsp:useBean> tag or using ${ELexpressions}
    All you can pass from the client to the server is request parameters - which are always strings.
    Draw a picture of where the information is, and the information flows. Very rarely does it go directly from one "form" to another.
    Cheers,
    evnafets

  • DO Web Service allow you to retrieve data from database and make it pluggab

    Can Web Services allo you to retrieve data from the database and do they make the pluggable by allow you to plug them into any database.. how is that possible....

    Going through the javaee tutorial is one sure way of accelerating your learning curve, as almost every basic you will need to get your job done is explaiined well in there. i have been using it to learn building enterprise application and is awesome good resource.
    seriously consider downloading it
    java.sun.com/javaee/5/docs/tutorial/doc/

  • Is there a way to retrieve data from database wihout using JDBC while using JPDK?

    Hi,
    I want to create a portlet using JPDK with extra render modes and edit/Edit defaults mode too. The detail and show renderer mode jsp's/servlets render data from database. Based on the personalized paramter, the data rendered in detail and show mode will be obtained from database.
    The articles in the PDK zip asks not to use JDBC for security vulnerability. Does that mean , I should not use JDBC to connect to db to get data. If not, what should I use ? How do I connect to database ? Is there any class which helps to connect to db without using JDBC ?
    thanks,
    Mainak

    I'm not sure what articles you are refering to, because there is no other way to access a database from a java program. Generally, security related docs tend to be a little paranoid (and so they should be), but you have to balance high security against getting the job done.
    Obviously, if using JDBC, you need to be careful about protecting your config files because they will contain connection information.

  • Not able to retrieve data from database through servlet

    Hi friends,
    I am trying to open a excel sheet through servlet. In this servlet i am retriving data from mssql database.I am not getting any error but no data is retrived
    i m also pasting the code here
    // Decompiled by Jad v1.5.8f. Copyright 2001 Pavel Kouznetsov.
    // Jad home page: http://www.kpdus.com/jad.html
    // Decompiler options: packimports(3)
    // Source File Name:   EmployeeData.java
    import java.io.*;
    import java.sql.*;
    import javax.sql.*;
    import javax.servlet.ServletException;
    import javax.servlet.http.*;
    public class EmployeeData extends HttpServlet
        public EmployeeData()
        public void service(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse)
            throws ServletException, IOException
            httpservletresponse.setContentType("text/html");
            httpservletresponse.setHeader("Content-Type", "application/excel");
            httpservletresponse.setHeader("Content-Disposition", "filename=reports.xls");
            PrintWriter printwriter = httpservletresponse.getWriter();
            try
                javax.servlet.http.HttpSession httpsession = httpservletrequest.getSession(true);
                int i = 0;
             /*   Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
                Connection connection = DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:3413;DatabaseName=newreportsodbc", "reportuser", "cisco");*/
                String url="jdbc:odbc:newreportsodbc";
                Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
                Connection connection = DriverManager.getConnection("jdbc:odbc:newreportsodbc","reportuser","cisco");
                Statement statement = connection.createStatement();
                printwriter.println("<b><center><u> Search Results </u></center></b>");
                printwriter.print("<table><tr><th color=brown background-color=#fff000>  No.  </th>");
                printwriter.print("<th> DateTime      </th></tr></table>");
           ResultSet resultset = statement.executeQuery("SELECT * FROM t_Call_Type_Half_Hour");
                boolean flag;
                for(flag = false; resultset.next(); flag = true)
                    i++;
                    SerialNo = resultset.getString(2);
                    printwriter.print((new StringBuilder()).append("<table><tr><td> ").append(i).append("</td>").toString());
                    printwriter.print((new StringBuilder()).append("<td> ").append(SerialNo).append("</td></tr></table>").toString());
                if(!flag)
                    printwriter.println("<h1> No records selected </h1>");
            catch(Exception exception)
                System.out.println((new StringBuilder()).append("SQLException: ").append(exception).toString());
        static String empid1;
        static String empid;
        static String SerialNo;
        static String designation;
    }thanks in advance. i just feel there is something to be done with connection string.

    post the table format in SQL

  • How to speed up retrieving data from database

    I write some code to get lots of data from mysql to draw many lines in my applet
    but when I run the program ,it run slowly.
    So I think it over to find a method.
    I do it like that:
    Use single Thread to get data from mysql to draw one single line.
    But when I executed my code.
    The error"Operation not allow after ResultSet closed".
    Have you come across such problems.
    I am sorry that my code is not at my hand.
    thanks very much.

    Sorry, it's not clear. Are you saying you're generating many threads, each with their own Resultset? Maybe several resultsets from the same Statement?
    I'm not sure a statement can support more than one Resultset at a time.
    In any case, whereas it probably makes sense to have a thread doing your database retrieval I would suspect multiple threads will actually make things worse, you're limited by the connection spead and how fast mySql can actually deliver the data.
    I think you may need to concentrate on the way that the database is set up and read and to judge that we'd need to see the SQL you're using to retrieve the data, and that for setting up the table you're reading from. You might find that, for example, adding appropriate indexes in the database might help. Or doing the SQL query a different way.

Maybe you are looking for

  • Error message when trying to delete a conditional tag.

    When attempting to delete a conditional tag, the following error occurred and then the program closed down: 0x00ca1940/ 0x00000000 Anyone come across this error. In addition, I have had similar errors occurred when resizing graphic frames. Once the e

  • Oracle Support Involvement on This List

    Does Oracle Tech Support ever post to this discussion list??? Calvin Mitchell, IS Operations Mgr. Makoff R&D Laboratories, Inc. http://www.rndlabs.com mailto:[email protected] http://home.pacbell.net/cal_mitc mailto:[email protected] mailto:[email pr

  • Dynamic datasource query in Content Presenter

    I have a Documents region with a custom Content Presenter template. I would like to use a dynamic datasource query with this, which makes use of the currently logged in user and the user's role. The task flow parameters look like this now: <parameter

  • GR Based Invoice Verifcation indicator

    Hello All, In the PO GR based Iv indicator is set. It is not selected in Vendor master and InfoRecord. Can anyone expalin the possibility of the indicator set. Thanks

  • Blackberry Desktop Software Hangs on Startup

    I installed the version that came with Curve 8330 (Verizon), on Dell Latitude 620 running Vista Ultimate. The Desktop started with the blank weavy screen but no menus. Hourglass. I waited for 30 minutes. No progress. I uninstalled, rebooted, download