1. [root@wx03 mojo]# cat relink.pl
  2. use Mojolicious::Lite;
  3. use JSON qw/encode_json decode_json/;
  4. use Encode;
  5. no strict;
  6. no warnings;
  7. use JSON;
  8. use POSIX;
  9. use JSON::RPC::Client;
  10. use Data::Dumper;
  11. use DBI;
  12. # /foo?user=sri`
  13. my %hash=();
  14. my $dbUser='DEVOPS';
  15. my $user="root";
  16. my $passwd="R00t,uHagt.xx";
  17. my $dbh = DBI->connect("dbi:mysql:database=$dbUser;host=127.0.0.1;port=3306",$user,$passwd) or die "can't connect to database ". DBI-errstr;
  18. get '/api/relink' => sub{
  19. my $c = shift;
  20. my @arr2=();
  21. my $env = $c->param('env');
  22. my $hostSql = qq{select ip,info,env from publish_info where env='$env';};
  23. my ($a1, $a2, $a3,$a4,$a5,$a6,$a7,$a8,$a9);
  24.  
  25. my $selStmt = $dbh->prepare($hostSql);
  26. $selStmt->execute();
  27. $selStmt->bind_columns(undef, \$a1, \$a2,\$a3);
  28. while( $selStmt->fetch() ){
  29. print "\$a1 is $a1\n";
  30. print "\$a2 is $a2\n";
  31. print "\$a3 is $a3\n";
  32. push (@arr2, "$a1 $a2 $a3" );
  33. };
  34.  
  35. $c->render(json => \@arr2);
  36. };
  37. app->start;
  38.  
  39. [root@wx03 ~]# curl http://127.0.0.1:3000/api/relink?env=test
  40. ["1.1.1.1 aa test"]
  41.  
  42. 停止数据库,启动数据库
  43. [][root@wx03 ~]# curl http://127.0.0.1:3000/api/relink?env=test
  44. [][root@wx03 ~]# curl http://127.0.0.1:3000/api/relink?env=test
  45. [][root@wx03 ~]
  46. [root@wx03 ~]# curl http://127.0.0.1:3000/api/relink?env=test
  47. [][root@wx03 ~]# curl http://127.0.0.1:3000/api/relink?env=test
  48. [][root@wx03 ~]# curl http://127.0.0.1:3000/api/relink?env=test
  49. [][root@wx03 ~]# curl http://127.0.0.1:3000/api/relink?env=test
  50. [][root@wx03 ~]# curl http://127.0.0.1:3000/api/relink?env=test
  51. [][root@wx03 ~]# curl http://127.0.0.1:3000/api/relink?env=test
  52. [][root@wx03 ~]# curl http://127.0.0.1:3000/api/relink?env=test
  53. [][root@wx03 ~]# curl http://127.0.0.1:3000/api/relink?env=test
  54. [][root@wx03 ~]# curl http://127.0.0.1:3000/api/relink?env=test
  55. [][root@wx03 ~]# curl http://127.0.0.1:3000/api/relink?env=test
  56. [][root@wx03 ~]# curl http://127.0.0.1:3000/api/relink?env=test
  57. [][root@wx03 ~]# curl http://127.0.0.1:3000/api/relink?env=test
  58. [][root@wx03 ~]# curl http://127.0.0.1:3000/api/relink?env=test
  59. [][root@wx03 ~]#
  60.  
  61. 代码报错:
  62. Server available at http://127.0.0.1:3000
  63. $a1 is 1.1.1.1
  64. $a2 is aa
  65. $a3 is test
  66. $a1 is 1.1.1.1
  67. $a2 is aa
  68. $a3 is test
  69. DBD::mysql::st execute failed: Lost connection to MySQL server during query at /root/mojo/relink.pl line 25.
  70. DBD::mysql::st bind_columns failed: Statement has no result columns to bind (perhaps you need to successfully call execute first, or again) at /root/mojo/relink.pl line 26.
  71. DBD::mysql::st fetch failed: fetch() without execute() at /root/mojo/relink.pl line 27.
  72.  
  73. DBD::mysql::st execute failed: MySQL server has gone away at /root/mojo/relink.pl line 25.
  74. DBD::mysql::st bind_columns failed: Statement has no result columns to bind (perhaps you need to successfully call execute first, or again) at /root/mojo/relink.pl line 26.
  75. DBD::mysql::st fetch failed: fetch() without execute() at /root/mojo/relink.pl line 27.
  76.  
  77. 没有自动重连

PERL DBI 自动重连问题的更多相关文章

  1. Netty 自动重连

    from: http://www.dozer.cc/2015/05/netty-auto-reconnect.html 自动重连 用 Netty 写 Client 和 Server 的时候必须要去处理 ...

  2. perl DBI 学习总结(转载)

    perl DBI 学习总结 源文地址:http://blog.csdn.net/like_zhz/article/details/5441946 DBI和DBD的不同关系模型: ########### ...

  3. 如何实现Azure虚拟网络中点到站VPN的自动重连

     在Windows Azure早期版本中,用户要在某台Azure平台之外的机器与Azure平台内部的机器建立专用连接,可以借助Azure Connect这个功能.当前的Azure版本,已经没有Az ...

  4. 解读dbcp自动重连那些事---转载

    http://agapple.iteye.com/blog/791943 可以后另一篇做对比:http://agapple.iteye.com/blog/772507 同样的内容,不同的描述方式,不一 ...

  5. NodeMCU之旅(二):断线自动重连,闪烁连接状态

    事件监听器 NodeMCU采用了事件响应的方式.也就是说,只需为事件设置一个回调函数,当事件发生时,回调函数就会被调用. 注册事件监听器 wif.sta.eventMonReg() 开始监听 wifi ...

  6. 【树莓派】树莓派下WiFi断线自动重连

    实现 WiFi 断线自动重连.原理是用 Python 监测网络是否断线,如果断线则重启网络服务. 1.Python 代码 autowifi.py,放在 /home/pi 目录下: #!/usr/bin ...

  7. WordPress 实现附件上传自动重命名但不改变附件标题

    WordPress 上传媒体文件时,默认会保持文件名不变.如果上传文件名中包含中文字符,则会造成部分浏览器显示的文件 URL 疑似乱码甚至无法访问.网上流行较广的是通过注册  wp_handle_up ...

  8. Oracle12c中SQL性能优化(SQL TUNING)新特性之自动重优化(automatic reoptimization)

    Oracle12c中的自动重优化 Oracle12c中的自适应查询优化有一系列不同特点组成.像自适应计划(AdaptivePlans)功能可以在运行时修改执行计划,但并不允许计划中连接顺序的改变.自动 ...

  9. 如何解决testng执行用例失败自动重跑问题

    注: 以下内容引自 http://blog.csdn.net/MenofGod/article/details/72846649 看过几个相关问题的帖子,内容类似,不过这篇解决问题的步骤和代码比较清晰 ...

随机推荐

  1. const和violate

    const修饰变量 C语言中,const修饰的变量是只读的,本质还是变量,修饰的变量也会在内存中占用空间(这不废话么)本质上const只对编译器有用,在运行时无用.const和类型顺序无要求,一般类型 ...

  2. [AngularJS] Using $parse Service

    $parse is useful when you want to parse an expression and the context is not defined yet. For exampl ...

  3. 各个函数消耗的时间profiling和内存泄漏valgrind

    来源:http://06110120wxc.blog.163.com/blog/static/37788161201333112445844/ ARM(hisi)上面的profiling和valgri ...

  4. Servlet的PrintWriter out = response.getWriter()使用

    一直以来,只知道out可以向客户端浏览器页面输入数据(html.txt等类型),今天在和php程序联调时发现自己的理解出现了偏差. out是输出字符流,即servlet接受到request请求后,se ...

  5. 在Mac中安装.Net Core的开发环境

    在mac中部署dotnet core开发环境,我的MacOS版本号为OSX EI Capitan 10.11.6 1.安装brew homebrew官网推荐的安装命令如下: /usr/bin/ruby ...

  6. Sandcastle Help File Builder使用教程

    Sandcastle Help File Builder相信很多的园友用过,小弟我最近因为工作原因需要生成公司的一套SDK的帮助文档,因此找了一些资料,发现网上的资料很多,但是都不怎么完全,有些只是随 ...

  7. CentOS6.3 Firefox安装FlashPlayer

    这段时间搞搞CentOS,我自己用的版本是CentOS6.3,基本上都差不多,过程都一样,主要说一下步骤 1.从Adoble官网下载FlashPlayer插件,下载地址:http://get.adob ...

  8. webform repeater

    repeater:由模板构成,解析后模板就不存在了             需要指定数据源进行数据绑定 List<Fruit> list = new FruitDA().Select(); ...

  9. hdu 2156

    #include <iostream> #include <stdio.h> using namespace std; int main() { int i,n; while( ...

  10. hdu 1728

    //hdu 1728 //这个是一道很经典的迷宫题了,思路感觉...取起点和终点,判断连线是否超过n个弯, //先是从起点出发,上下左右四个方向搜索,找到一条路,把那条路的第一个点压入队列 //然后沿 ...