Is there a possibility to call a stored procedure on the MSSQL DB without java to wait for a return

Discussion in 'Java' started by gagu911@gmx.ch, Nov 30, 2005.

  1. Guest

    Hello
    Im working with jdbc on a MSSQL Database.

    In my java client im executing a stored procedure called myProc on the
    database.
    Im doing this with the following code:

    ......
    Statement stmt = con.createStatement();
    String sql1 ="execute myProc";
    stmt.execute(sql1);

    My problem is, that this stored procedure takes at least one hour to
    finish. So i cant close the java client during this time, otherwise the
    stored procedure will be canceled. I can call it in a seperate thread,
    but that doesnt help. Nevertheless the client cant be closed.

    Is there a possibility to call a stored procedure on the MSSQL DB
    without java to wait for a return value?

    Thanks in advance
    G. Agu
     
    , Nov 30, 2005
    #1
    1. Advertising

  2. Guest

    Did you consider maybe running a SQL Server job? You could fire your
    procedure from the job, and I guess SQL Server jobs can be run
    asynchronously with a SQL statement. If you arrange your application
    that way, your Java client can just start the job and quit.

    Regards,

    Bartosz Klimek
     
    , Nov 30, 2005
    #2
    1. Advertising

  3. Guest

    Couldn't find a solid answer right away, but here goes :
    perhaps MSSQL has a connection property 'blocking' that you can set ?
    If it doesn't a solution could be to start a different process
    altogether, through Runtime's exec.
    Let you know if I think of something else..

    Paul Hamaker
    http://javalessons.com
     
    , Nov 30, 2005
    #3
  4. Guest

    Thanks Bartosz for the immediate answer!

    The hint to use a sql server job helped a lot.
    Here is how I solved the problem:
    thats the java code:
    Statement stmt = con.createStatement();
    String sql1 ="USE msdb EXEC sp_start_job 'verdichten'";
    System.out.println(sql1);
    stmt.execute(sql1);
    It is Important to use the msdb Database which is given by MSSQL, there
    the sp_start_job procedure is stored.

    In MSSQL: The name of my sql job is called 'verdichten'. In this job i
    call my stored procedure. The stored procedure is not in msdb, of
    course. It's in my own DB i use in the project.

    Greetz and 'schönä bim stöhnä'
    G. Agu
     
    , Nov 30, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. TJS
    Replies:
    2
    Views:
    682
    Kevin Spencer
    Feb 11, 2004
  2. Lacka
    Replies:
    2
    Views:
    860
    Lacka
    Dec 31, 2004
  3. =?Utf-8?B?ZGF2aWQ=?=
    Replies:
    3
    Views:
    412
    =?Utf-8?B?ZGF2aWQ=?=
    Oct 20, 2006
  4. Richard Morey
    Replies:
    3
    Views:
    552
    Richard Morey
    Jan 22, 2004
  5. Alexander Tretjakov

    MSSQL 2005 Stored Procedure?

    Alexander Tretjakov, Mar 14, 2008, in forum: Ruby
    Replies:
    4
    Views:
    293
    Damjan Rems
    Mar 25, 2008
Loading...

Share This Page