1 Reply Latest reply on Jun 4, 2015 10:53 AM by aJohny

    getStatement().toString() not printing query

    km1612

      I am executing a query and trying to print that in my log file but getting some junk values.

       

      Code :

                           rs = st.executeQuery("SELECT full_name, employee_number FROM per_all_people_f "

                                                      +  " WHERE employee_number = '" +empno +"'");

                                                     

                           Stt = rs.getStatement().toString();

       

                       logfile.writeln((new StringBuilder()).append("Query :").append(Stt).toString(), 1);

       

      Output log :

       

      Query :oracle.jdbc.driver.OracleStatementWrapper@2580258

       

      Why is it not printing the appropriate query ?

      Is there any other way to achieve this functionality ?

       

      Thanks

        • 1. Re: getStatement().toString() not printing query
          aJohny

          Not sure what you are trying to achieve ? Just trying to print the Query used ?

           

          If Yes, just assign the query to a String before executing, and use the string for executing and the same for printing.


          Does this help ?

           

          String str  = "SELECT full_name, employee_number FROM per_all_people_f WHERE employee_number = '" +empno +"’”;

          rs = st.executeQuery(str);

          //Stt = rs.getStatement().toString();

          logfile.writeln(str, 1);


           

          Cheers

          AJ