May 20, 2013 at 7:47 am
Hi Team,
I want a java batch file to be executed in a trigger, is it possible to call JAVA class file in SQL Trigger.
Please suggest..?
May 20, 2013 at 9:16 am
Minnu (5/20/2013)
Hi Team,I want a java batch file to be executed in a trigger, is it possible to call JAVA class file in SQL Trigger.
Please suggest..?
You could probably use xp_cmdshell. However I don't think I would recommend doing this in a trigger. I would instead use your trigger to populate a table and then have a sql job that will execute your code for all the rows in that table.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
May 20, 2013 at 9:19 am
I Agree,
But job will not work in my scenario,
i want only, when ever any event (insert/update/delete), then only i want to execute the java batch file,
Please help...
May 20, 2013 at 9:23 am
xp_cmdshell.
http://msdn.microsoft.com/en-us/library/ms175046.aspx
I have a feeling that performance is going to be absolutely hideous if you do this in a trigger.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
May 20, 2013 at 9:39 am
sorry,
bit communication GAP,
i want to call .java files in sql trigger....
Is it possible...?
May 20, 2013 at 9:48 am
Minnu (5/20/2013)
sorry,bit communication GAP,
i want to call .java files in sql trigger....
Is it possible...?
Yes you would need to use xp_cmdshell.
SQL server is not a JVM so you need to use xp_cmdshell to use something that can process it.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
May 20, 2013 at 9:49 am
Minnu (5/20/2013)
sorry,bit communication GAP,
i want to call .java files in sql trigger....
Is it possible...?
No you cannot, not directly,
you have to call the operating system via xp_cmdshell to call the java runtime environment to execute the java file (.jar?) along with the parameters the package might expect, with no interaction whatsoever(confirmation boxes, forms opening,etc, ).
so your java has to already exists and be able to accept variables via the command line like the poor example below, you can do as Sean mentioned but did not recommend in a trigger;
when i just called the example below, it took five whole seconds for the jar to execute; thats a crippling amount of wait time inside a trigger, so i'll echo Seans recommendation to do the work outside of the trigger.
If there is info inside the trigger and nowhere else that is needed, then All you need to do is log that critical info to a processing table, and loop thru the processing table as a scheduled job.
pdfmergerSB545.jar C:\DataFiles\Header.pdf C:\DataFiles\Content.pdf C:\DataFiles\Tail.pdf
Lowell
May 20, 2013 at 2:54 pm
Minnu (5/20/2013)
Hi Team,I want a java batch file to be executed in a trigger, is it possible to call JAVA class file in SQL Trigger.
Please suggest..?
Just exactly what does this JAVA class file do?
--Jeff Moden
Change is inevitable... Change for the better is not.
May 20, 2013 at 3:15 pm
One more option might be to use CLR integration, to get at the JAR from one of the integration libraries (such as IKVM). This will make the parameter passing somewhat easier, but stlll likely to run into perf issues if you're talking about large batches.
If the use case makes sense - you may consider going for service broker instead: publish the changes to a queue and wire it into the JAR through JMS. Queuing will alleviate the performance bottleneck, as long as you don't need synchronous feedback.
Without knowing what the JAR actually does, it's going to be hard to give you any form of intelligent answer.
----------------------------------------------------------------------------------
Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply