2013-08-07 102 views
1

訪問xsjs文件我新的SAP HANA,並試圖通過與以下URL網頁瀏覽器,露出.xsjs文件數據:無法從瀏覽器

hostname:80<instance#>/workspace/session/a00/data/services/retrieveData.xsjs 

不過,我收到以下錯誤,當我嘗試訪問它:

此鏈接似乎中斷我們無法找到您嘗試訪問的資源。它可能拼錯或當前不可用

這些都是我在項目資源管理器中創建的文件:

MYSCHEMA.hdbschema

schema_name="MYSCHEMA" 

trendsData.hdbtable

table.schemaName = "MYSCHEMA";               
table.tableType = COLUMNSTORE; 
table.description = "NewDataSet Order trendsData"; 

table.columns = [ 


     {name= "C"; sqlType = NVARCHAR; nullable = true; length=10; }, 
     {name= "D"; sqlType = VARCHAR; nullable = true; length=5; }, 
     {name= "DU"; sqlType = NVARCHAR; nullable = true; length=20; }, 
     {name= "SA"; sqlType = DECIMAL; nullable = true; length=30; }, 
     {name= "I"; sqlType = DECIMAL; nullable = true; length=30; }, 
     {name= "G"; sqlType = DECIMAL; nullable = true; length=30; }, 
     {name= "G"; sqlType = DECIMAL; nullable = true; length=20; }, 
     {name= "STR"; sqlType = DECIMAL; nullable = true; length=30; } 
     ]; 
table.primaryKey.pkcolumns = ["INVENTORY"]; 

orderId.hdbsequence

schema="MYSCHEMA";  
start_with=2000000; 
cycles=false;  
depends_on_table="workspace.session.a00.data::trendData"; 

retrieveData.xsjs

$.response.contentType="text/html";                  
var output = "Helloworld";                     
var conn = $.db.getConnection(); 

var pstmt = conn.prepareStatement("select * from trendData"); 

var rs = pstmt.executeQuery(); 

if (!rs.next())                     
{ 
    $.response.setBody("Failed to retrieve data"); 
    $.response.status = $.net.http.INTERNAL_SERVER_ERROR; 
} 

else                       
{                        
output=output + "This is the respose from my SQL: "              
+ rs.getString(1);                     
}                       
rs.close();                     
pstmt.close();                   
conn.close();                 
$.response.setBody(output); 

上述所有文件都成功地承諾,並與出任何錯誤激活。仍然,錯誤發生在webrowser。

回答

1

您確定您在瀏覽器中輸入的網址是否已正確構建?

的URL應該建立以下列方式:

服務器:端口/則repository_path/FILE_NAME

一個錯誤的路徑可能會導致您的問題。請看下面的例子:

主機:hanacloud
端口:8000(80 + INSTANCE_NUMBER)

SAP HANA的版本樹
MDO - >
                       樹液 - >
                                              SFLIGHT - >
                                                                           測試 - >
                                                                               個                    test.xsjs

網址:hanacloud:8000/MDO/SAP/SFLIGHT /檢驗/試驗。xsjs

1

你的端口號應該是8000,而不是80,並確保不堵塞網絡,通常情況下,上,尤其是在辦公網絡

0

你的SELECT語句不指定模式。另外,表格的目錄名稱通常是「包名稱::表格名稱」。此外,您的表定義具有兩個具有相同名稱和無效主鍵規範的列。

因此我期望選擇失敗。作爲第一步,我會建議嘗試

$.response.contentType = "text/plain"; 
$.response.setBody('hello world'); 
$.response.status = $.net.http.OK; 

一旦你得到這個運行,你知道,在網絡接入工程。我的下一步是將所有東西都包裝成一些try/catch,如

var eString = ""; 
try { 

    //* 
     * your code goes here 
     *// 

    return; // do not forget this! 
} catch (e) { 
    eString = "\nException.toString(): " + e.toString() + "\n"; 
    var prop = ""; 
    for (prop in e) { 
     eString += prop + ": " + e[prop] + "\n"; 

    response.status = $.net.http.INTERNAL_SERVER_ERROR; 
    response.contentType = "plain/text"; 
    response.setBody(eString); 
    return; 
} 

response.status = $.net.http.INTERNAL_SERVER_ERROR; 
response.contentType = "plain/text"; 
response.setBody("something went badly wrong"); 

然後,這將允許查明您的代碼的確切位置。

0

請確保存在.xsaccess和.xsapp文件以及語法。還要承認文件已被激活。