interupt JDBC SQL query connection

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mike Read

    interupt JDBC SQL query connection

    Hi

    I using Java and JDBC to connect to MS SQL server 2000 (using the MS
    drivers msbase,msutil and mssqlserver.jar s).

    Sometimes it takes a long time for statement.execu teQuery
    to return and start returning the resultset
    (full DB scan can take 30-40 minutes).

    Does anyone know if it's possible to interupt/halt the query before
    it eventually comes back. The setQueryTimeout works OK but this has to be
    set quite high to allow real queries to run correctly. What I'm trying
    to do is allow users to halt their query if they've realised they
    want to alter it or its taking too long. The query is running in a
    separate thread and I've tried using the main thread to close the
    connection or stop the query but this still waits until the resultset
    is returned.

    Maybe it's a driver issue or .....

    Thanks
    Mike
  • John Bell

    #2
    Re: interupt JDBC SQL query connection

    Hi

    I am not sure about the JDBC driver itself, but you could use a timer thread
    to kill it off.

    John

    "Mike Read" <mar@roe.ac.u k> wrote in message
    news:Pine.OSF.4 .58.04060915013 20.263861@reaxp 06.roe.ac.uk...[color=blue]
    > Hi
    >
    > I using Java and JDBC to connect to MS SQL server 2000 (using the MS
    > drivers msbase,msutil and mssqlserver.jar s).
    >
    > Sometimes it takes a long time for statement.execu teQuery
    > to return and start returning the resultset
    > (full DB scan can take 30-40 minutes).
    >
    > Does anyone know if it's possible to interupt/halt the query before
    > it eventually comes back. The setQueryTimeout works OK but this has to be
    > set quite high to allow real queries to run correctly. What I'm trying
    > to do is allow users to halt their query if they've realised they
    > want to alter it or its taking too long. The query is running in a
    > separate thread and I've tried using the main thread to close the
    > connection or stop the query but this still waits until the resultset
    > is returned.
    >
    > Maybe it's a driver issue or .....
    >
    > Thanks
    > Mike[/color]


    Comment

    • perry

      #3
      JBuilderX and Together

      how many people here get the luxery of creating and maintaining apps in
      jbuilder and together everyday? care to share any stories, either great
      or not so great! i just got an eval of the latest and greatest installed
      and after using previous versions for years, what i see now looks really
      great. just was wondering about your experiences.

      cheers

      - perry

      Comment

      • Alfredo Diaz

        #4
        Re: JBuilderX and Together

        I'm just new in the Java World and also JBuilder X Enterprise IDE. I'm
        making a servlet client , using Struts , because the MVC pattern is just what
        we need for our application.
        Until now this is working just fine. I like the IDE, autocompletion, colors,
        indent, etc.
        The progam gives a lots of tips and help using class, packages, etc.

        Greetings.....



        In comp.lang.java perry <perry@cplusplu s.org> wrote:
        : how many people here get the luxery of creating and maintaining apps in
        : jbuilder and together everyday? care to share any stories, either great
        : or not so great! i just got an eval of the latest and greatest installed
        : and after using previous versions for years, what i see now looks really
        : great. just was wondering about your experiences.

        : cheers

        : - perry


        --
        Alfredo Diaz
        =============== =
        School of Engineering and Science, University of Chile
        Beaucheff 850, P.O. Box 2777, Santiago, CHILE
        mailto:aadiaz@d cc.uchile.cl.no spam

        Comment

        • Erland Sommarskog

          #5
          Re: interupt JDBC SQL query connection

          Mike Read (mar@roe.ac.uk) writes:[color=blue]
          > I using Java and JDBC to connect to MS SQL server 2000 (using the MS
          > drivers msbase,msutil and mssqlserver.jar s).
          >
          > Sometimes it takes a long time for statement.execu teQuery
          > to return and start returning the resultset
          > (full DB scan can take 30-40 minutes).
          >
          > Does anyone know if it's possible to interupt/halt the query before
          > it eventually comes back. The setQueryTimeout works OK but this has to be
          > set quite high to allow real queries to run correctly. What I'm trying
          > to do is allow users to halt their query if they've realised they
          > want to alter it or its taking too long. The query is running in a
          > separate thread and I've tried using the main thread to close the
          > connection or stop the query but this still waits until the resultset
          > is returned.[/color]

          You will have to examine the documetation for the JDBC driver. Most
          client APIs for SQL Server supplies functions for asynchronous calls.
          With a asynch call, you could then issue a cancel request (again this
          is offered by most client APIs).

          microsoft.publi c.sqlserver.jdb cdriver may offer more exact answers with
          regards to that driver.


          --
          Erland Sommarskog, SQL Server MVP, esquel@sommarsk og.se

          Books Online for SQL Server SP3 at
          Get the flexibility you need to use integrated solutions, apps, and innovations in technology with your data, wherever it lives—in the cloud, on-premises, or at the edge.

          Comment

          Working...