我有一个jqgrid,它调用perl-cgi来填充网格。cgi使用DBD::Oracle来获取数据。网格未显示数据。
调试脚本时,我发现在准备语句时存在冲突。当我跳过准备,只发送数据时,它工作得很好;当我从Oracle改为PostgreSQL时,它运行得很好。
有人经历过吗?我知道CGI与Oracle连接一起工作,因为当我交互运行它时,它会运行并打印到屏幕上。当从网格调用CGI时,它不会。当使用Pg连接调用CGI并进行准备时,数据加载到网格完美
CGI:
#!/usr/bin/perl
use CGI;
use DBI;
use Connect::Oracle;
use Connect::PG;
$stat = new CGI("");
print $stat->header;
$count = $stat->url_param('count');
#connecting to either db works fine
my $ORdbh = DBI->connect(Oracle->User, {PrintError=>1,RaiseError=>1});
# my $ORdbh = DBI->connect(PG->User, {PrintError=>1,RaiseError=>0});
$select = qq/select * from db.table/;
# preparing with Oracle connection works fine, but nothing returned to grid.
# Not even the hardcoded $rows below!
# Preparing with PG connection works also but $rows returns to grid
my $select_batch_status = $ORdbh->prepare($select);
#$select_batch_status->execute();
#$select_batch_status->bind_columns($COLLECTID, $SYSTEM);
....removed fetch()....irrelevant
#The JSON is fine
$rows = qq/["COLLECTID","SYSTEM"]/;
$data = qq/{"page":"1","total": 1, "records": "$row_count", "rows": [/;
$data .= $rows;
$data .= qq/]}/;
print "$data";
exit;
我得出的结论是,jqgrid和DBD::Oracle之间存在冲突,但我不知道如何调试更低的版本。网格与Pg配合得很好,但我想使用Oracle。在Chrome开发者工具上,我没有看到任何警告或错误,cgi也没有发送任何数据
网格:
<script type="text/javascript">
var counter=0;
jQuery(function () {
jQuery("#list3").jqGrid({
url:'./collect.cgi?count=' + counter,
datatype: "json",
ajaxGridOptions: { contentType: 'application/json; charset=utf-8' },
colNames: ['COLLECT ID', 'SYSTEM'],
colModel: [
{name: 'collectid', index: 'collectid', width: 100},
{name: 'system', index: 'system', width: 50},
],
rowNum: 20,
rowList: [15, 30, 45],
pager: '#pager3',
sortname: 'system',
sortable: true,
loadonce: true,
viewrecords: true,
sortorder: "asc",
rowTotal: 500,
jsonReader: {
cell: "",
id: "0"
},
gridview: true,
loadComplete: function() {
$(document).ready(function() {
setTimeout (function() {
counter++;
$("#list3").jqGrid().setGridParam({
url: './collect.cgi?count=' + counter,
datatype: 'json',
loadonce: true
}).trigger("reloadGrid",[{current:true}]);
}, 10000);
});
},
loadError: function(xhr,st,err) {
$("#jsonmapMessage").html("Type: " + st + "; Response: " + xhr.status + " " + xhr.statusText);
},
loadtext: "updating...",
caption: "COLLECTION MONITOR CONTROL",
width: 'auto',
height: '500'
});
$("#list3").jqGrid('navGrid','#pager3',{edit:true,add:true,del:true,refresh:true});
});
</script>
我最近能够重新访问它,经过一些挖掘和web日志审查,发现cgi程序无法加载DBD::Oracle所需的所有库。为了使这些库可用,我必须更新LD_LIBRARY_PATH env变量以指向正确的库。在cgi程序获取其环境的Web服务器级别需要进行此更改。将LD_LIBRARY_PATH添加到脚本中没有任何影响。在我的Web服务器:Oracle iPlanet上,我需要更新server.xml配置文件的cgi部分,并重新启动Web服务器(从管理控制台进行更改没有成功)