Monday 27 February 2017

HANA XS: Javascript -Database API's ($.db)

SAP HANA XS Database API($.db) provides tools that enable simple and convenient access to database.
  1.  $.db.getConnection().
    It returns $.internal.api.Connection object which has below method.
    1. close()
      closes the connection.
    2. commit()
      commits the connection.
    3. isClosed()
      Checks if connection is closed or not.
    4. prepareCall()
      Prepares a stored procedure for execution.
      Returns $.internal.api.CallableStatement object.
    5. prepareStatement(statement)
      Prepares a statement fro execution.
      Returns $.internal.api.PreparedStatement object and following methods.
      1. executeQuery()
        Executes an SQL statement and returns $.internal.api.ResultSet object and has below methods.
        1. getString(column Index).
          Return String for a specified columns.
        2. next()
          Iterates to next row of result set.
      2. executeUpdate()
        execute the update statement and returns the number of changed rows.
    6. rollback()
      Rolls back the changes.
    7. setAutoCommit()
      Changes the auto commit flag of the connection.
  2. Example:

    1. Create below table by writing below SQL on console.
    2. Write following code in javascript file to access the table's data by using database API.
    3. Run the .xsjs file as HANA XS service.




No comments:

Post a Comment