Hello,
I am creating a code to connect to database using .xsjs in XS engine. It is displaying error "Access Forbidden" as in the screenshot:
Below is the code that i am executing in my .xsjs file to display data.
$.response.contentType = "text/html";
var output = "Access Users records !";
var conn = $.db.getConnection();
var getRow = conn.prepareStatement( "select * from DUMMY" );
var getrs = getRow.executeQuery();
if (!getrs.next()) {
$.response.setBody( "Failed to retrieve data" );
$.response.status = $.net.http.INTERNAL_SERVER_ERROR;
}
else
{
output = output + "This is the response from my SQL: " + getrs.getString(1);
}
getrs.close();
getRow.close();
conn.close();
$.response.setBody(output);
When executing the below:
$.response.contentType = "text/html";
var output = "Access Users records !";
$.response.setBody(output);
It displays the message as "Access Users records !".
Any suggestion will be helpful.