mysql curl,通过执行本地操作系统的命令(例如curl),通过MySQL调用HTTP GET请求

I am using MySQL 5.6.11 running on 32-bit Microsoft Windows XP (Professional Version 2002 Service Pack 3). I installed the MySQL sys_exec UDF. Since I am running on 32-bit Windows, I used this

Afterwards, the following command was executed (after logging in into an already created database).

mysql> CREATE FUNCTION sys_exec RETURNS INT SONAME 'lib_mysqludf_sys.dll';

Query OK, 0 rows affected (0.02 sec)

I had already created a PL/SQL stored procedure as follows.

DELIMITER $$

CREATE DEFINER=`root`@`localhost` PROCEDURE `country_push`()

BEGIN

SET @result=sys_exec('curl http://localhost:8080/ContextPath/push-update-country');

END

This procedure is supposed to be invoked by database triggers (which is adequately done) and accordingly, it should raise an HTTP GET request on the said URL but no HTTP GET request is raised on the URL, when this stored procedure is executed by a trigger on a certain event.

Manually executing the procedure on the command line succeeds as well, as follows.

mysql> CALL country_push();

Query OK, 0 rows affected (0.08 sec)

The sys_exec() function returns 1 as follows which is a success flag.

mysql> SELECT sys_exec('curl http://localhost:8080/ContextPath/push-update-country')

AS result;

+--------+

| result |

+--------+

| 1 |

+--------+

1 row in set (0.06 sec)

There is already a Java Servlet running on GlassFish (4.1) application server which is supposed to listen to this HTTP GET request as follows.

@WebServlet(name = "PushCountry", urlPatterns = {"/push-update-country"})

public class PushCountry extends HttpServlet {

@Override

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

System.out.println("PushCountry called.");

}

}

The line System.out.println("PushCountry called."); in the doGet() method produces nothing on the server terminal (because it is not executed/invoked), when the above-mentioned MySQL stuff is put into practice.

Is it not practical to do this using MySQL, is there something else I might be missing or is it the old EOL dinosaur : Windows XP?

The shared Dynamic Link Library I am using might not be suitable. Please clarify, if such is a case as this is beyond me.

EDIT:

When entering,

mysql> SELECT sys_eval('id');

MySQL terminates/crashes with the following error report.

dfc6d5343a17a80ef5ef680a0c5b69db.png

On closing this dialog, MySQL leaves the following error message.

ERROR 2013 (HY000): Lost connection to MySQL server during query

It fails to reconnect until/unless the system itself is restarted.

Perhaps, I will think of reinstalling the operating system itself later on.

解决方案

seems that 'id' is a Linux command not existing under Windows...

anyway i also get trouble with sys_exec() under windows that return a number but no process is launched.

For info it works well under linux.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值