on 04-18-2015 12:45 AM
Hi,
I created my first helloworld.xsjs file in SAP HANA trail version and was successfully able to retrieve data from DUMMY table.
Then I created a TEST1 table in NEO_45GGLHBRNEL4HTIE2H0ZR0LUY schema and inserted test values in this table. When I tried to access the data in this TEST1 table through .xsjs file, I got an error as
Found the following errors: ===========================
InternalError: dberror(Connection.prepareStatement): 258 - insufficient privilege: Not authorized at ptime/query/checker/query_check.cc:2422 (line 12 position 0 in /p1873072661trial/hihanatrial/helloworld/helloworld.xsjs)
Could you please let me know how can I get access to this table from .xsjs file
The .xsjs code:
$.response.contentType = "text/html";
var output = "Hello World!<br><br>";
//Open a database connection
var conn = $.db.getConnection();
//var pstmt = conn.prepareStatement("insert into DEV_3NNM3EIKNP8VVHWQNM9CPLF1I.TEST values (1,'A')");
//var rs = pstmt.executeQuery();
//Prepare a simple SQL statement on the system table "DUMMY"
var pstmt1 = conn.prepareStatement("select * from NEO_45GGLHBRNEL4HTIE2H0ZR0LUY.TEST1");
//Execute the query
var rs = pstmt1.executeQuery();
//Check the query result
if (!rs.next()) {
//Something went wrong: Return an error
$.response.setBody("Failed to retrieve data");
$.response.status = $.net.http.INTERNAL_SERVER_ERROR;
} else {
//All went fine: Return the Query result
output = output + "This is the response from my SQL: " + rs.getString(1);
}
//Close the database connection
rs.close();
pstmt.close();
conn.close();
//Return the HTML response.
$.response.setBody(output);
Thanks,
Krishna
Hi Sandeep,
Just have to include this statement in the roles folder -> role access file:
catalog sql object "NEO_XXXXXXXXX"."TABLE NAME": SELECT;
It worked for me. Please let me know if even you are able to access your table data from .xsjs file.
Thanks,
Krishna
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sandeep,
I am using student trial account and have created roles folder in the same path as .xsjs file. Please find the screenshot below. I think you can create a similar .hdbrole file and use the following code:
role pXXXXXXtrial.hihanaxs.hihanaxs.roles::model_access
{catalog sql object "NEO_7KXXXXXXXXXXXXXU"."TEST1": SELECT;}
hi Krishna,
I created similar role file in the same folder of helloworld.xsjs, and also put your code into the role file, however, it doesn' work...
helloworld.xsjs:
err:
Found the following errors:
===========================
InternalError: dberror(Connection.prepareStatement): 258 - insufficient privilege: Not authorized (line 8 position 1 in /i074178trial/stock/helloworld.xsjs)
confused...
Hi, I am also able to retrieve data from DUMMY table but it is giving "insufficient Privilege" when I tried to retrieve from my table. Did you find the issue. Please help me with this.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Krishna,
You got solution to the above problem. How you have resolved it. Can you please brief me about the same.
Regards,
Pallavi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Krishna,
Thank you for your response.
Am using SAP HANA Trail account as how you have used in the sample code. Is HANA trail is student trial account which you would like to say, will it doesn't work if we have trial account as specified. Hope the above code which you have shared worked fine for you without trial account.
Regards,
Pallavi
Hi Krishna,
... trial accounts do not have the permissions to write to database....
this is not true.
The issue here is that you are trying to insert data into the wrong database schema DEV_3NNxxxxxxxxxF1I. This is the user/schema which you can access the DB with. Your data should be stored in the schema NEO_45GxxxxxxxxxxxLUY.
Best regards
Xu
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.