Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Is there a possibility to call a stored procedure on the MSSQL DB without java to wait for a return value?

Reply
Thread Tools

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

 
 
gagu911@gmx.ch
Guest
Posts: n/a
 
      11-30-2005
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

 
Reply With Quote
 
 
 
 
bartekkl@gmail.com
Guest
Posts: n/a
 
      11-30-2005
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

 
Reply With Quote
 
 
 
 
ph@semm.tmfweb.nl
Guest
Posts: n/a
 
      11-30-2005
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

 
Reply With Quote
 
gagu911@gmx.ch
Guest
Posts: n/a
 
      11-30-2005
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
MSSQL 2005 Stored Procedure? Alexander Tretjakov Ruby 4 03-25-2008 06:43 AM
Need help: Call server side Stored Procedure and get the return va =?Utf-8?B?ZGF2aWQ=?= ASP .Net 3 10-20-2006 04:09 PM
How to call parameterized stored procedure to return result set? Lacka ASP .Net 2 12-31-2004 03:39 PM
wait until stored procedure is complete TJS ASP .Net 2 02-11-2004 02:22 PM
Execute a stored procedure from ASP page, but don't wait for it to complete? Richard Morey ASP General 3 01-22-2004 01:14 AM



Advertisments