The following
example shows how to use $.db interface
to connect to SAP Hana Db and how to read data from db and how to response as
json object.
The example values
assumes that we have country data in DB .
COUNTRYID
|
COUNTRYNAME
|
1
|
India
|
2
|
USA
|
3
|
UK
|
/////if you have sqlcc configuration please use in the get Connection method.
var conn = $.db.getConnection();
var query = "SELECT COUNTRYID,
COUNTRYNAME "SCHEMA"."table name";
var pstmt =
conn.prepareStatement(query);
var rs = pstmt.executeQuery();
while(rs.next())
{
data.push
({
"COUNTRYID":rs.getString(1),
"COUNTRYNAME":rs.getString(2),
});
}
No comments:
Post a Comment