Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2005

Tip: Looking for answers? Try searching our database.

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

Thread view: 
gagu911@gmx.ch - 30 Nov 2005 11:53 GMT
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
bartekkl@gmail.com - 30 Nov 2005 13:35 GMT
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
gagu911@gmx.ch - 30 Nov 2005 15:59 GMT
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
ph@semm.tmfweb.nl - 30 Nov 2005 14:34 GMT
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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.