"The operation was cancelled at the user's request" error during mass insertions

From: Jeeji (jeejim_at_india.hp.com)
Date: 11/17/04

  • Next message: Prithpal: "Re: Padding using Type 4 Drivers"
    Date: 16 Nov 2004 22:11:17 -0800
    
    

    Hi,

    I am facing a strange problem using SQL server 2000 version with JDBC
    driver for SQL server 2000 version SP1/SP3. I have a table with
    name-value pairs and I populate the table from a properties file. When
    I am doing the insertions in a for loop, it is failing intermittently
    with the error with SP1 version:

    java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]The
    operation
    was cancelled at the user's request.
            at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown
    Source
    )
            at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown
    Source)
            at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReplyToken(Unknown
     Source)
            at com.microsoft.jdbc.sqlserver.tds.TDSRPCRequest.processReplyToken(Unkn
    own Source)
            at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReply(Unknown
    Sour
    ce)
            at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processOutstandingCancelA
    cknowledgements(Unknown Source)
            at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReply(Unknown
    Sour
    ce)
            at com.microsoft.jdbc.sqlserver.SQLServerImplStatement.getNextResultType
    (Unknown Source)
            at com.microsoft.jdbc.base.BaseStatement.getNextResultType(Unknown
    Sourc
    e)
            at com.microsoft.jdbc.base.BaseStatement.executeUpdateInternal(Unknown
    S
    ource)
            at com.microsoft.jdbc.base.BasePreparedStatement.executeUpdate(Unknown
    S
    ource)

    The error with SP3 version:

    java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for
    JDBC]Execution time
    out expired.
            at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown
    Source
    )
            at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown
    Source)
            at com.microsoft.jdbc.base.BaseStatement.preprocessExceptionFromCommonEx
    ecute(Unknown Source)
            at com.microsoft.jdbc.base.BaseStatement.executeUpdateInternal(Unknown
    S
    ource)
            at com.microsoft.jdbc.base.BasePreparedStatement.executeUpdate(Unknown
    S
    ource)

    The source code is given below:

    PreparedStatement pstmt = null;
    pstmt = con.prepareStatement("INSERT INTO Configuration(uid, name,
    value) VALUES (?,?,?);");
    FileInputStream fileSettings = new FileInputStream("test.properties");
    Properties props = new Properties();
    props.load(fileSettings);

    // get the name and value for each property in the file
    for(Enumeration en = props.propertyNames();en.hasMoreElements();)
    {
    String name = (String) en.nextElement();
    String value = props.getProperty(name);

    boolean exist = isAlreadyPresent(name);
    if(!exist)
    {
    nextUID++;
    setNextUid(nextUID); //update nextUid in the table Uid
    pstmt.setLong(1,nextUID); // update new uid
    pstmt.setString(2,name);
    pstmt.setString(3,value);
    pstmt.executeUpdate();
                                                                                            }
    }
            con.commit();
    }
                     catch(SQLException ex)
                     {
                            ex.printStackTrace();
                    }
                     finally
                     {

                             pstmt.close();
                     }
            }

    The problem was consistently reproduced after I commented the line
    setNextUid which is in between the consecutive insertions to the same
    table. Please also note that the problem vanished completely when I
    gave Thread.sleep(100) in between each of the inserts. I am suspecting
    this is a driver related bug though I may be completely wrong. Please
    advice on any slution. Is there a driver version where this bug has
    been fixed ? Any pointers on this would be helpful.

    IMPORTANT: This is a single-threaded code.

    Thanks a lot.
    -Jeeji


  • Next message: Prithpal: "Re: Padding using Type 4 Drivers"
    Loading