cancel
Showing results for 
Search instead for 
Did you mean: 

xssqlcc can not work

former_member197620
Participant
0 Kudos

Hi experts,

I create an AdminConn.xssqlcc file. In HANA XS Admin Tool I set the following configration:

And I add the content    "anonymous_connection" : "test::AdminConn"   in .xsaccesss file.

But I execute the test.xsjs,  the error page display:

test.xsjs

function test() {

  var body;

  var conn;

  $.response.status = $.net.http.OK;

  try {

  conn = $.db.getConnection("test::AdminConn");

  var pStmt = conn.prepareStatement("select CURRENT_USER from dummy");

  var rs = pStmt.executeQuery();

  if (rs.next()) {

  body = rs.getNString(1);

  }

  rs.close();

  pStmt.close();

  } catch (e) {

  body = "Error: exception caught";

  $.response.status = $.net.http.BAD_REQUEST;

  }

  if (conn) {

  conn.close();

  }

  $.response.setBody( body );

}

test();

The xssqlcc can work, what should I do?

Candy Zhang

Accepted Solutions (1)

Accepted Solutions (1)

pfefferf
Active Contributor
0 Kudos

Hello,

there can be several reasons why it does not work (e.g. auto generated user has not enough rights, ...).

Please can you return the message of the exception object to get a hint on what is wrong (-> replace your line "body = "Error: exception caught" by "body = e.message").

One problem is that your xssqlcc file is in a a different package (test) than your xsjs service (test/services). The xssqlcc file must be in the same package than the app (or service) which uses it.

Best Regards,

Florian

former_member197620
Participant
0 Kudos

Florian, thank you! I resolve the issue.

BR,

Candy Zhang

Answers (0)