I have a MySQL stored procedure. I would like to have a stored procedure run some statements, then call a Java program. Then when the java program is complete, the stored procedure should finish.
The java program will connect to the database, do some analysis and then insert rows into other tables.
Is this possible?
Yes. Take a look at The MySQL UDF Repository and the sys_exec function. You could use this to launch your Java code in a new JVM.
After you get that installed here is how you run it: https://dba.stackexchange.com/a/39547/14506
Related
I'm hosted a MySql database on Amazon RDS, and I'm looking to create a Stored Procedure that will ping my NAS at home and log the results to a table. I'm looking to create a log of my home internet outages.
I'm new to MySql and have no idea how to ping something from a Stored Procedure, and every search on google appears to be on how to ping a MySql server, not how to ping from a MySql stored procedure.
In mssql I can ping using the following method:
DECLARE #pingAddress VARCHAR(200) = 'ping www.google.ca'
EXEC master..xp_cmdshell #pingAddress
Is there anyway to achieve the same affect in MySql?
You shouldn't ping or do anything else outside the database in a stored procedure. Stored procedures are for manipulating data in MySQL.
If you want to log your home internet outages, there are services that do that for you, for example https://www.pingdom.com/free
If you prefer to do it yourself with custom code, write an application and host it on a small EC2 instance, or else run a Lambda function on a schedule or something like that.
Here's a blog about how one person did it with a Lambda: https://medium.com/#nzoschke/http-service-health-monitor-w-lambda-a9f475abbbf4
In a native MySQL unextended by user-defined functions, You Can't Do Thatâ„¢.
There may be a suitable set of user-defined functions if you must do it. But doing this sort of thing within a MySQL database is something zealously to be avoided.
Here is the UDF repository.
https://github.com/mysqludf
I have created a stored procedure in mysql workbench located on server. I need to call this stored procedure through a vba application located on local machine. I am stuck on it unable to connect to mysql stored procedure. Thanks in advance for responses .
Have you setup a DSN with an ODBC connection yet?
Assuming so - check out simple examples at
It wasn't hard to find this on Google
DAO Examples
I want to backup my MySQL database , can I do it by using procedures or routines. I mean if i call a procedure, and pass the path where the file is to be exported to the procedure, then the procedure will make the backup. How can I write such a procedure or routine.
Thanks!
The MySQL itself cannot make backup, you should do it from the outside, e.g. run mysqldump or another client program. But for your case (...using routines and procedures) you could try to use user-defined function, it may help you to run backup process.
I found tutorials on creating a stored procedures on the net, I just don't understand when exactly do I need to execute the creation of the stored procedure.
do the stored procedures creation should be executed each time i restart my MySQL server ?
do I need to execute the stored procedures creation sql each time I start my application?
Stored procedures are persisted to the database, ie they will be there even after a restart of the database server. You create them once and then you run them as often as you need. Of course you may want to change them sometimes using an alter statement.
How do I create a stored procedure for mysql using VB .NET programmatically?
EDIT:
Apologize to be so brief. I have tried using ExecuteNonQuery provided by MySQL .NET Connector. It prompts me error. Maybe it's because I put "Delimiter $$"?
I know I can create using script (batch file) if I want to send it to my client (as commented below). But my objective is to keep MySQL password safe. So script is not the way.
Connect to the database.
Run the create procedure SQL command using ExecuteNonQuery