2

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?

1 Answer 1

1

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...

Sign up to request clarification or add additional context in comments.

4 Comments

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.
What are you entering as argument? what steps have you followed? Provide some more details....
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.
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?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.