I am using MySQL UDF function sys_exec
for calling Java program inside a trigger of MySQL. Can you please provide me the information about how I pass argument to sys_exec
so that it will call Java program?

- 19,824
- 17
- 99
- 186

- 3,284
- 9
- 38
- 51
1 Answers
You can use this link to use sys_exec function. It says,
sys_exec sys_exec takes one command string argument and executes it. Syntax
sys_exec(arg1) Parameters and Return Values
arg1 : A command string valid for the current operating system or execution environment. returns An (integer) exit code returned by the executed process. Installation
Place the shared library binary in an appropriate location. Log in to mysql as root or as another user with sufficient privileges, and select any database. Then, create the function using the following DDL statement: CREATE FUNCTION sys_exec RETURNS INT SONAME 'lib_mysqludf_sys.so'; The function will be globally available in all databases. The deinstall the function, run the following statement: DROP FUNCTION sys_exec;
For executing Java program you should fill arg1 as "java <absolute path to precompiled program to run>"
.
Note: path to java should be configured before hand.
Hope it helps...

- 5,223
- 3
- 28
- 43
-
shubhansh I have done every thing but not been able to correct argument which can make java program to call. Can you please provide me info about that argument String that is taken by sys_exec. – Satish Sharma Sep 17 '12 at 14:25
-
What are you entering as argument? what steps have you followed? Provide some more details.... – jsist Sep 17 '12 at 14:35
-
sys_exec('java /home/Desktop/helloWorld') this is passed as an argument. helloWorld here is a class which is being not called by exec function. – Satish Sharma Sep 17 '12 at 14:41
-
Are you able to execute the above mentioned command through terminal? Is path to java is set in system variables? Does your MySQL have sufficient privileges to start new process. Try running MySQL server as root and then check. What is the return value? – jsist Sep 18 '12 at 05:38