cancel
Showing results for 
Search instead for 
Did you mean: 

Public call to XSJS and $.db

roberto_falk
Participant
0 Kudos

Hi Colleagues,

I'm creating a html page that will enable the users to put the <iNumber> and the HANA user will be created in our local sandbox. To do it, I've created a procedure that creates the user, and I'm trying to call it from a XSJS file.

The problem is the following, since my page is public, since the idea is that everyone can access it and create the user, when the XSJS code gets the statement $.db.getConnection(); an error is returned: Error: db.getConnection: expects an authenticated session

Do you know how to pass the user and password for the connection, or do you have a different idea to solve my problem ?

Thanks and regards,

Roberto Falk

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Roberto Falk,

For Calling the database from xsjs,the session needs a username and password. Usually we pass it from the UI which istakeninthe xsjs. But if this is not case, you can have something as SQL Connection Configuration File i.e. xssqlcc that must be created and a database user to beassociated with it.

We need to then associate the connection file in the xsjs to db connection or you can provide it in the xsaccess file as anonymous connection.

The details can be found in Developer guide http://help.sap.com/hana/SAP_HANA_Developer_Guide_en.pdf section 8.5.

Thanks and Regards,

Anjali.

Answers (2)

Answers (2)

roberto_falk
Participant
0 Kudos

Perfect, exactly what I need. Thank you all!!

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

You need to create an xssqlcc object and maintain the reference to that object in the xsaccess for this service or add the xssqlcc reference to the database connection in your xsjs code.  Via this xssqlcc you can maintain the user name and password which will be used in the database connection for anonymous applications.  Just search in the HANA Developers' Guide for xssqlcc. It details all the steps involved pretty well.

Former Member
0 Kudos

Hi Thomas , i followed the same steps mentioned above but getting the below error.

Error while executing query: [db.getConnection: not allowed to access SQL connection configuration from this package]

I assigned User as SYSTEM .

Please help me with this error.

Thanks,

Vinod

thomas_jung
Developer Advocate
0 Kudos

The XSSQLCC must be the in the same package as the XSJS trying to use it. From the error it sounds like you are trying to use one from a different package.

Former Member
0 Kudos

No Thomas ,

its in the same package, my annonuser.xssqlcc

and my xsjs file is in services folder.

thomas_jung
Developer Advocate
0 Kudos

Services folder is a different package. Not the same package hierarchy but actually the same package.

Former Member
0 Kudos

Thanks Thomas, it worked when i moved my xsjs file out of services folder and placed beside xssqlcc file, don't know why but worked fine

Thanks,

Vinod

thomas_jung
Developer Advocate
0 Kudos

>don't know why but worked fine

Because the XSJS file and the XSSQLCC file must be in exactly the same package for security reasons.