2012-09-21 55 views
0

我有一個jqgrid調用perl cgi來填充網格。 cgi使用DBD :: Oracle來獲取數據。網格不顯示數據。jqgrid ajax與perl cgi和dbd oracle

調試腳本我發現在語句準備好時會發生衝突。當我跳過準備,只是發送數據,它工作正常;當我從Oracle更改爲PostgreSQL時,它工作得很好。

任何有經驗的人嗎?我知道CGI正在使用Oracle連接,因爲它在我以交互方式運行時運行並打印到屏幕上。當從網格調用CGI時,它不會。當CGI被稱爲與PG的連接和準備,將數據加載到網格 - 完美

的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 ::甲骨文,但之間的衝突我不知道如何調試任何更低。該網格與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> 

回答

0

我能最近重溫這一點,經過一番挖掘和網絡日誌審查結果顯示,cgi程序無法加載DBD :: Oracle所需的所有庫。爲了使這些庫可用,我必須更新LD_LIBRARY_PATH env變量以指向正確的庫。在CGI程序獲取環境的網絡服務器級別需要進行此更改。將LD_LIBRARY_PATH添加到腳本沒有任何影響。在我的網絡服務器上:Oracle iPlanet,我需要更新server.xml配置文件的cgi部分,並重新啓動網絡服務器(使管理控制檯的更改不會粘住)