4 Replies Latest reply on Jan 24, 2013 11:50 AM by jane_lj

    Return result of Statement.execute(sqlstring)

    jane_lj

      I have my updat function ready in my Teiid tranlator, when I run standard sql statement in Java, it can update the data source successfully, the only issue I have is the return result of Statement.execute("udpate xxx set xxxxx") is always false, even some records have been updated.

       

      I miss something in code to implement it correctly?

       

      Thanks.

        • 1. Re: Return result of Statement.execute(sqlstring)
          shawkins

          Check the Javadoc for Statement.execute, it will return true if a result set is available.  You should just be checking Statement.getUpdateCount()

           

          Steve

          1 of 1 people found this helpful
          • 2. Re: Return result of Statement.execute(sqlstring)
            jane_lj

            Can you send me a code example for override method UpdateExecution.getupdateCount() in teiid,maybe I'm wrong with this part?

             

            Thanks.

            • 3. Re: Return result of Statement.execute(sqlstring)
              rareddy

              Jane,

               

              What Steve said above is, when you execute a statement like "Statement.execute("udpate xxx set xxxxx")", it will only be returning the Statement.getUpdateCount(), which indicates how many records have been updated with your update statement.

               

              However if you executed "statement.execute('select * from ....')", which does return a resultset, but you do not know whether you executed the first form above or the second from, the "statement.execute" itself "returns" a boolean. If that return is true, then you can call statement.getResultSet(), if false, then you can only call statement.getUpdateCount()

               

              All this explained in the javadoc for the statement class.

               

              Hope this helps.

               

              Ramesh..

              1 of 1 people found this helpful
              • 4. Re: Return result of Statement.execute(sqlstring)
                jane_lj

                Thank you, Steven and Ramesh.