Re: execute() vs executeUpdate() on a prepared statement





AArora wrote:

I ran into this issue when running ANY update or delete statements. I also ran into this when running any DDL statements.

This also happens with executeBatch(). See bug FDBK44661.
There should be a simple example there.


I'm surprised that the driver was actually released with such bugs.

Anil

Again, please show the JDBC. I was unable to duplicate this problem with this code:

          DatabaseMetaData dd = c.getMetaData();
          System.out.println("Driver version is " + dd.getDriverVersion() );

          Statement stmt = c.createStatement();
          stmt.execute("create table #foo(bar int)");

          String insert_if_absent =
            " declare @qwe int "
          + " select @qwe = count(*) from #foo where bar = 1 "
          + " if (@qwe = 0) insert into #foo values(1) ";

          stmt.execute(insert_if_absent);
          stmt.execute(insert_if_absent);
          stmt.execute(insert_if_absent);
          stmt.execute(insert_if_absent);

          stmt.execute("select count(*) from #foo");
          ResultSet r = stmt.getResultSet();
          while(r.next())
          System.out.println("We inserted " + r.getString(1) + " row." );

I get:
Driver version is 1.0.809.102
We inserted 1 row.

as expected.
Joe



"Joe Weinstein" wrote:



BJinDallas wrote:

We have been using JDBC drivers for 2000 for some time without problems using an execute() call against a prepared statement when performing an sql update with where clause. After upgrading to the new 2005 drivers this call now receives the error: "sp_cursoropen/sp_cursorprepare: The statement parameter can only be a single select or a single stored procedure." If I change it to call executeUpdate() instead, it works fine. What's changed in the 2005 drivers that no longer supports use of execute() when it did before?

Please show the JDBC that prepares the statement for execution, and if you can show us the SQL as well, that would be very useful. At first blush this sounds like a definite driver bug. Execute() is supposed to work for *any* SQL or procedure. Joe Weinstein at BEA



.



Relevant Pages

  • Re: execute() vs executeUpdate() on a prepared statement
    ... The issue was that a cursor may error out if the back-end function is too ... execute may attempt to create a cursor. ... the 2005 driver is NOT using the same code ... See bug FDBK44661. ...
    (microsoft.public.sqlserver.jdbcdriver)
  • Re: execute() vs executeUpdate() on a prepared statement
    ... the bug quickly,thanks. ... Server 2005 JDBC Driver ... execute may attempt to create a cursor. ... As you can tell the most important part of the repro is the SQL used ...
    (microsoft.public.sqlserver.jdbcdriver)
  • Re: Windows Scheduling on I/O bound systems with >2 cores/processo
    ... Each process does the continuous read & write DMA operations ... CPU usage: On <= 2 processor systems, ... We are running Load test on our PCI IO card(WDF driver), ... On machines with>2 processors a single process would execute its read ...
    (microsoft.public.development.device.drivers)
  • Re: execute() vs executeUpdate() on a prepared statement
    ... I have the same problem.I use the rtwjdbc driver connect ... the bug quickly,thanks. ... Server 2005 JDBC Driver ... execute may attempt to create a cursor. ...
    (microsoft.public.sqlserver.jdbcdriver)
  • Re: CPU Pegged at 100%
    ... Enquire, plan and execute ... Windows Image Acquisition and select Properties. ... Updated video driver, no effect. ...
    (microsoft.public.windowsxp.perform_maintain)

Loading