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.