hdb
SAP's pure JavaScript driver for connecting Node.js apps directly to SAP HANA, with no native bindings required.
Repository Health
Technical Analysis
hdb is SAP’s official pure JavaScript driver for connecting Node.js applications directly to SAP HANA Cloud and SAP HANA Platform databases, with no native compiled bindings or external client libraries required. It implements the SAP HANA wire protocol from scratch — connection negotiation, authentication, statement execution, and result parsing — entirely in JavaScript, making it straightforward to install and deploy across platforms, including sandboxed and Chrome App-style environments.
The driver supports direct and prepared statement execution, bulk inserts, streaming of large result sets and LOB (large object) columns, multi-statement transactions, and multiple authentication mechanisms (password, SAML, JWT, LDAP, X.509, and SCRAM-SHA256). It also handles SAP HANA’s multiple-container (MDC) tenant database topology, the CESU-8 text encoding required by the HANA wire protocol, and multi-host connection failover for production deployments.
What You Get
- A dependency-free wire-protocol implementation of the SAP HANA client protocol, with no native bindings to compile or ship
- Direct and prepared statement execution APIs (exec, execute, prepare) with callback-based results
- Streaming support for large result sets and LOB columns via Node.js readable/writable streams
- Multiple authentication mechanisms out of the box: user/password, SAML assertions, JWT, LDAP, X.509, and SCRAM-SHA256
- Multi-statement transaction handling with explicit commit/rollback control
- Support for SAP HANA multiple-container (MDC) tenant databases and multi-host failover configurations
Common Use Cases
- Node.js backend integration - services that need to query or write to an SAP HANA database directly from application code
- ETL and data pipelines - streaming large result sets or bulk-inserting rows into HANA tables from Node.js jobs
- Large object handling - reading and writing BLOB/CLOB columns as Node.js streams for document or file storage in HANA
- Transactional workflows - multi-statement operations wrapped in commit/rollback transactions from a Node.js service layer
Under The Hood
Architecture The library layers cleanly: Client.js is the public-facing EventEmitter-based API that composes a Connection responsible for wire-protocol state, a Statement/Result pair for prepared/direct execution, and a ConnectionManager for connection lifecycle; below that, PhysicalConnection.js and tcp.js manage the actual socket, while Parser.js, Reader.js and Writer.js implement message-level packet/segment/part framing, and the part/, request/, and reply/ directories model each SAP HANA protocol message as its own file, closely mirroring the wire format’s own structure. Authentication is factored into a dedicated auth/ directory with one file per mechanism (SAML, JWT, LDAP, SCRAM-SHA256, X.509, session cookie) behind a common auth manager, and ConnectionTopology.js/ConnectionManager.js separately handle MDC tenant routing and multi-host failover — a modular, protocol-driven design where changing the core connection/message-framing layer would ripple through the auth, part, and reply modules that depend on its format.
Tech Stack Plain JavaScript (CommonJS, no TypeScript, no build step) targeting Node.js 18+, with a single production dependency (iconv-lite, for CESU-8/text encoding conversions) and an optional native-free WASM package for LZ4 decompression; development tooling is mocha and should for testing, c8 for coverage, and jshint for linting, driven through a Makefile. A browser field in the package manifest swaps the TCP transport module for a Chrome-sockets-based implementation, letting the same codebase run inside a Chrome App sandbox, and CI runs an integration test suite against a live SAP HANA server across multiple current Node.js versions.
Code Quality An extensive test suite covers nearly every protocol part, request, and reply type individually, plus acceptance and database-integration suites that exercise a live HANA instance in CI; error handling is explicit throughout, with a dedicated error type modeling HANA error codes and severities as first-class objects, and parsing/connection code checking buffer bounds and message kinds rather than silently swallowing failures. The codebase predates TypeScript adoption, so there is no static type safety — only jshint-based linting — but naming is consistent and closely mirrors the SAP HANA wire protocol’s own terminology, and the presence of live-server integration tests across several Node.js versions is a notably thorough quality signal for a driver of this kind.
What Makes It Unique The library’s distinguishing technical choice is implementing the full SAP HANA client wire protocol — segment/part framing, CESU-8 encoding, and LZ4 decompression — entirely in JavaScript with zero native bindings, in contrast to SAP’s other supported driver, which wraps a compiled native client library. This trade-off is explicit in the project’s own documentation, which weighs it against features like connection pooling and automatic reconnect that the native driver offers instead, and it is this portability trade-off — including the ability to swap transports and run inside a browser-like sandbox — that is the project’s main point of technical distinction rather than a wholly novel capability.