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 / Databases / October 2004

Tip: Looking for answers? Try searching our database.

Java running MS-SQL job?

Thread view: 
Mike - 08 Oct 2004 21:56 GMT
Is there a way in Java to run an MS-SQL saved job?

I have a saved job called test, I can run the following in the Query
Analyzer and it runs fine:

SQL CODE
Exec msdb.dbo.sp_start_job @job_name = 'test'
END SQL CODE

I tried running this out of java, but get The specified @job_name
('test') does not exist.  Here is what I am doing.

I have a database connection before this and I know it works fine.

CODE
String t_job="test";
    PreparedStatement state = con.prepareStatement("EXEC
msdb.dbo.sp_start_job @job_name =?");
    state.setString(1, t_job);
    boolean rs_exists = state.execute();
END CODE

I have a few scripts and dts packages that I want users to run instead
of scheduling.  I can set these scripts and dts packages to run as SQL
jobs. It would be great if I could provide a list of these jobs in an
html form and pass the parameter off to a jsp such as this that would
run the proper job.

Thanks in advance.
Andy Flowers - 11 Oct 2004 12:38 GMT
Have you tried looking at CallableStatement ?

See also Connection.PrepareCall(...)

> Is there a way in Java to run an MS-SQL saved job?
>
[quoted text clipped - 25 lines]
>
> Thanks in advance.
Nathan Zumwalt - 11 Oct 2004 18:41 GMT
Is a saved job like a stored procedure?

http://java.sun.com/j2se/1.4.2/docs/api/java/sql/CallableStatement.html

//Nathan

> Is there a way in Java to run an MS-SQL saved job?
>
[quoted text clipped - 25 lines]
>
> Thanks in advance.


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.