Unexpected Exception when inserting data in SQL 2000

Tech-Archive recommends: Fix windows errors by optimizing your registry



Our application has run for years using the SQL 2000 JDBC and the jTDS
driver. I recently tried using the SQL 2005 driver, and I'm getting
unexpected behavior. Here is the scenario...

We have code that inserts data into an SQL table that has a primary key
constraint on one of the columns being inserted. At times, the code
will insert a row that violates the primary key constraint. This is an
expected behavior, and we catch the exception and check for the error
code of 2627, which tells us that this is the case. The code is using a
prepared statement, which is re-used for each insert call.

The SQL 2005 is giving us the exception as expected. However, later on,
it keeps throwing the exception when it shouldn't be. The same
preparedstatement is set with different values, which are unique and
not already in the database table. The PreparedStatement.execute() call
is throwing an SQLException with an error code of 2627. I've examined
the preparedstatement in the debugger, and it's parameter values are
unique. I've tried profiling the call, and I don't even see the
statement hitting the database.

What is going on? Has anyone else seen this?

Andrew Elmhorst

.



Relevant Pages

  • Re: SQL 2005 Profiler
    ... printer Microsoft Office Document Image Writer is unknown. ... administrator to install the driver before you log in again. ... Note that if the default trace is enabled, it is directed to the SQL Server log folder. ...
    (microsoft.public.sqlserver.security)
  • Re: TDBC documentation, examples, syntax?
    ... current SQL standards. ... for variable binding at the Tcl level. ... API, I'd probably use Oracle's bound session variables and pass ... As a convenience for driver writers, ...
    (comp.lang.tcl)
  • RE: XA transactions
    ... Which driver and version are you using and where did you locate these ... | I used the following set of instructions to enable XA transactions on our ... | SQL box: ... Create a registry named-value: ...
    (microsoft.public.sqlserver.jdbcdriver)
  • Re: Behavior of Connection.commit()
    ... Does it say "commit" and "rollback" and other SQL commands that affect the transaction state are not allowed? ... How sure can the driver ever be about the state of the transaction? ...
    (microsoft.public.sqlserver.jdbcdriver)
  • Re: Unexpected Exception when inserting data in SQL 2000
    ... I recently tried using the SQL 2005 driver, ... unexpected behavior. ... We have code that inserts data into an SQL table that has a primary key ... the preparedstatement in the debugger, ...
    (microsoft.public.sqlserver.jdbcdriver)