[root@wx03 mojo]# cat relink.pl
use Mojolicious::Lite;
use JSON qw/encode_json decode_json/;
use Encode;
no strict;
no warnings;
use JSON;
use POSIX;
use JSON::RPC::Client;
use Data::Dumper;
use DBI;
# /foo?user=sri`
my %hash=();
my $dbUser='DEVOPS';
my $user="root";
my $passwd="R00t,uHagt.xx";
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;
get '/api/relink' => sub{
my $c = shift;
my @arr2=();
my $env = $c->param('env');
my $hostSql = qq{select ip,info,env from publish_info where env='$env';};
my ($a1, $a2, $a3,$a4,$a5,$a6,$a7,$a8,$a9); my $selStmt = $dbh->prepare($hostSql);
$selStmt->execute();
$selStmt->bind_columns(undef, \$a1, \$a2,\$a3);
while( $selStmt->fetch() ){
print "\$a1 is $a1\n";
print "\$a2 is $a2\n";
print "\$a3 is $a3\n";
push (@arr2, "$a1 $a2 $a3" );
}; $c->render(json => \@arr2);
};
app->start; [root@wx03 ~]# curl http://127.0.0.1:3000/api/relink?env=test
["1.1.1.1 aa test"] 停止数据库,启动数据库
[][root@wx03 ~]# curl http://127.0.0.1:3000/api/relink?env=test
[][root@wx03 ~]# curl http://127.0.0.1:3000/api/relink?env=test
[][root@wx03 ~]
[root@wx03 ~]# curl http://127.0.0.1:3000/api/relink?env=test
[][root@wx03 ~]# curl http://127.0.0.1:3000/api/relink?env=test
[][root@wx03 ~]# curl http://127.0.0.1:3000/api/relink?env=test
[][root@wx03 ~]# curl http://127.0.0.1:3000/api/relink?env=test
[][root@wx03 ~]# curl http://127.0.0.1:3000/api/relink?env=test
[][root@wx03 ~]# curl http://127.0.0.1:3000/api/relink?env=test
[][root@wx03 ~]# curl http://127.0.0.1:3000/api/relink?env=test
[][root@wx03 ~]# curl http://127.0.0.1:3000/api/relink?env=test
[][root@wx03 ~]# curl http://127.0.0.1:3000/api/relink?env=test
[][root@wx03 ~]# curl http://127.0.0.1:3000/api/relink?env=test
[][root@wx03 ~]# curl http://127.0.0.1:3000/api/relink?env=test
[][root@wx03 ~]# curl http://127.0.0.1:3000/api/relink?env=test
[][root@wx03 ~]# curl http://127.0.0.1:3000/api/relink?env=test
[][root@wx03 ~]# 代码报错:
Server available at http://127.0.0.1:3000
$a1 is 1.1.1.1
$a2 is aa
$a3 is test
$a1 is 1.1.1.1
$a2 is aa
$a3 is test
DBD::mysql::st execute failed: Lost connection to MySQL server during query at /root/mojo/relink.pl line 25.
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.
DBD::mysql::st fetch failed: fetch() without execute() at /root/mojo/relink.pl line 27. DBD::mysql::st execute failed: MySQL server has gone away at /root/mojo/relink.pl line 25.
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.
DBD::mysql::st fetch failed: fetch() without execute() at /root/mojo/relink.pl line 27. 没有自动重连

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. 桌面环境与桌面搜索Desktop Search tools

    最近一段时间工作重心都将放在Linux下Desktop search(桌面搜索)框架的研发上.因此对desktop search进行了初步的调研.本文将从下面三个方面展开: Linux桌面环境(Des ...

  2. [Javascript] Advanced Reduce: Flatten, Flatmap and ReduceRight

    Learn a few advanced reduction patterns: flatten allows you to merge a set of arrays into a single a ...

  3. Jquery UI的datepicker插件使用

    原文链接;http://www.ido321.com/375.html Jquery UI是一个非常丰富的Jquery插件,而且UI的各部分插件能够独自分离出来使用.这是其它非常多Jquery插件没有 ...

  4. Android BroadcastReceiver实例Demo(有序广播的发送)

    上一篇简介了广播的发送,这篇主要介绍下,有序广播的发送. 设置完相关属性的时候,广播就会依照有序的方式进行发送: 发送顺序: 先发送第二条广播: 再发送第一条广播: 最后发送第三条广播. 代码例如以下 ...

  5. 逆拓扑排序 HDU2647Reward

    这个题如果用邻接矩阵的话,由于n比较大,会超内存,所以选用邻接表的形式.还有就是这个题有那个等级的问题,一级比一级的福利高,所以不能直接拓扑排序,而是反过来,计算出度,找出度为0的顶点,然后更新出度数 ...

  6. Android Studio 安装

    准备: JDK 7以及以上版本. Android Studio安装文件  中文站下载 http://www.android-studio.org/index.php/download exe ,包含S ...

  7. html:标签原本属性

    <!doctype html>无标题文档 a标签,默认有text-decoration属性 span标签不需要清零 b标签不需要清零 em标签不需要清零 strong 相邻内嵌元素代码里面 ...

  8. c-100米球反弹

    #include <iostream> #define TIMES 10 int main(void) { ; ; //第一次反弹的高度. ; i <= TIMES; i++) { ...

  9. maven中pom.xml

    1. GroupID是项目组织唯一的标识符,实际对应JAVA的包的结构,是main目录里java的目录结构. ArtifactID就是项目的唯一的标识符,实际对应项目的名称,就是项目根目录的名称.一般 ...

  10. The account '' has no team with ID ''

    Xcode 升级到7.2 版本,真机测试的时候报错:The account '' has no team with ID '' 解决办法1:http://stackoverflow.com/quest ...