teradatasql
Version:
Teradata SQL Driver for Node.js
590 lines (454 loc) • 208 kB
Markdown
## Teradata SQL Driver for Node.js
This package enables Node.js applications to connect to the Teradata Database.
This package requires 64-bit Node.js v18.20.7 or later and runs on the following operating systems and processor architectures. 32-bit Node.js is not supported.
* Windows x64 on 64-bit Intel and AMD processors
* macOS on 64-bit ARM processors
* macOS on 64-bit Intel processors
* Linux x64 on 64-bit Intel and AMD processors
* Linux ARM64 on 64-bit ARM processors
For community support, please visit [Teradata Community](https://support.teradata.com/community).
For Teradata customer support, please visit [Teradata Customer Service](https://support.teradata.com/).
Please note, this driver may contain beta/preview features ("Beta Features"). As such, by downloading and/or using the driver, in addition to agreeing to the licensing terms below, you acknowledge that the Beta Features are experimental in nature and that the Beta Features are provided "AS IS" and may not be functional on any machine or in any environment.
Copyright 2026 Teradata. All Rights Reserved.
### Table of Contents
* [Features](#Features)
* [Limitations](#Limitations)
* [Installation](#Installation)
* [License](#License)
* [Documentation](#Documentation)
* [Sample Programs](#SamplePrograms)
* [Using the Driver](#Using)
* [Async Connection Management](#AsyncConnectionManagement)
* [Connection Parameters](#ConnectionParameters)
* [FIPS Mode](#FIPSMode)
* [COP Discovery](#COPDiscovery)
* [Stored Password Protection](#StoredPasswordProtection)
* [Logon Authentication Methods](#LogonMethods)
* [Client Attributes](#ClientAttributes)
* [User STARTUP SQL Request](#UserStartup)
* [Session Reconnect](#SessionReconnect)
* [Transaction Mode](#TransactionMode)
* [Auto-Commit](#AutoCommit)
* [Data Types](#DataTypes)
* [Null Values](#NullValues)
* [Undefined Values](#UndefinedValues)
* [Character Export Width](#CharacterExportWidth)
* [Module Constructors](#ModuleConstructors)
* [Module Exceptions](#ModuleExceptions)
* [Connection Attributes](#ConnectionAttributes)
* [Connection Methods](#ConnectionMethods)
* [Cursor Attributes](#CursorAttributes)
* [Cursor Methods](#CursorMethods)
* [Type Objects](#TypeObjects)
* [Escape Syntax](#EscapeSyntax)
* [FastLoad](#FastLoad)
* [FastExport](#FastExport)
* [CSV Batch Inserts](#CSVBatchInserts)
* [Parquet Batch Inserts](#ParquetBatchInserts)
* [JSON Batch Inserts](#JSONBatchInserts)
* [CSV Export Results](#CSVExportResults)
* [Command Line Interface](#CommandLineInterface)
* [Change Log](#ChangeLog)
<a id="Features"></a>
### Features
At the present time, the driver offers the following features.
* Supported for use with Teradata database 16.20 and later releases.
* [COP Discovery](#COPDiscovery).
* Laddered Concurrent Connect.
* [Non-blocking asynchronous connection operations](#AsyncConnectionManagement) with comprehensive operation enforcement.
* [HTTPS](https://en.wikipedia.org/wiki/HTTPS)/[TLS](https://en.wikipedia.org/wiki/Transport_Layer_Security) connections with Teradata database 16.20.53.30 and later.
* Encrypted logon.
* [GSS-API](https://en.wikipedia.org/wiki/Generic_Security_Services_Application_Program_Interface) logon authentication methods `KRB5` (Kerberos), `LDAP`, `TD2`, and `TDNEGO`.
* [OpenID Connect (OIDC)](https://en.wikipedia.org/wiki/OpenID#OpenID_Connect_(OIDC)) logon authentication methods `BEARER`, `BROWSER`, `CODE`, `CRED`, `JWT`, `ROPC`, and `SECRET`.
* Data encryption provided by TLS for HTTPS connections.
* For non-HTTPS connections, data encryption governed by central administration or enabled via the `encryptdata` connection parameter.
* Recoverable Network Protocol and Redrive.
* Unicode character data transferred via the UTF8 session character set.
* [Auto-commit](#AutoCommit) for ANSI and TERA transaction modes.
* Result set row size up to 1 MB.
* Multi-statement requests that return multiple result sets.
* Most JDBC escape syntax.
* Parameterized SQL requests with question-mark parameter markers.
* Parameterized batch SQL requests with multiple rows of data bound to question-mark parameter markers.
* Auto-Generated Key Retrieval (AGKR) for identity column values and more.
* Large Object (LOB) support for the BLOB and CLOB data types.
* Complex data types such as `XML`, `JSON`, `DATASET STORAGE FORMAT AVRO`, `DATASET STORAGE FORMAT CSV`, and `DATASET STORAGE FORMAT PARQUET`.
* ElicitFile protocol support for DDL commands that create external UDFs or stored procedures and upload a file from client to database.
* `CREATE PROCEDURE` and `REPLACE PROCEDURE` commands.
* Stored Procedure Dynamic Result Sets.
* FastLoad and FastExport.
* Monitor partition.
<a id="Limitations"></a>
### Limitations
* The UTF8 session character set is always used. The `charset` connection parameter is not supported.
<a id="Installation"></a>
### Installation
Use `npm install teradatasql` to download and install the driver and its dependencies automatically.
<a id="License"></a>
### License
Use of the driver is governed by the [License Agreement for the Teradata SQL Driver for Node.js](https://github.com/Teradata/nodejs-driver/blob/develop/LICENSE).
When the driver is installed, the `LICENSE` and `THIRDPARTYLICENSE` files are placed in the `teradatasql` directory under your `node_modules` installation directory.
In addition to the license terms, the driver may contain beta/preview features ("Beta Features"). As such, by downloading and/or using the driver, in addition to the licensing terms, you acknowledge that the Beta Features are experimental in nature and that the Beta Features are provided "AS IS" and may not be functional on any machine or in any environment.
<a id="Documentation"></a>
### Documentation
When the driver is installed, the `README.md` file is placed in the `teradatasql` directory under your `node_modules` installation directory. This permits you to view the documentation offline, when you are not connected to the Internet.
The `README.md` file is a plain text file containing the documentation for the driver. While the file can be viewed with any text file viewer or editor, your viewing experience will be best with an editor that understands Markdown format.
<a id="SamplePrograms"></a>
### Sample Programs
Sample programs are provided to demonstrate how to use the driver. When the driver is installed, the sample programs are placed in the `teradatasql/samples` directory under your `node_modules` installation directory.
The sample programs are coded with a fake database hostname `whomooz`, username `guest`, and password `please`. Substitute your actual database hostname and credentials before running a sample program.
Program | Purpose
-------------------------------------------------------------------------------------------------------------------- | ---
[AGKRBatchInsert.ts](https://github.com/Teradata/nodejs-driver/blob/develop/samples/AGKRBatchInsert.ts) | Demonstrates how to insert a batch of rows with Auto-Generated Key Retrieval (AGKR)
[AGKRInsertSelect.ts](https://github.com/Teradata/nodejs-driver/blob/develop/samples/AGKRInsertSelect.ts) | Demonstrates Insert/Select with Auto-Generated Key Retrieval (AGKR)
[AsyncConnectClose.ts](https://github.com/Teradata/nodejs-driver/blob/develop/samples/AsyncConnectClose.ts) | Demonstrates non-blocking asynchronous connection establishment and closure using connectAsync and closeAsync
[BatchInsert.ts](https://github.com/Teradata/nodejs-driver/blob/develop/samples/BatchInsert.ts) | Demonstrates how to insert a batch of rows
[BatchInsertCSV.ts](https://github.com/Teradata/nodejs-driver/blob/develop/samples/BatchInsertCSV.ts) | Demonstrates how to insert a batch of rows from a CSV file
[BatchInsertJSON.ts](https://github.com/Teradata/nodejs-driver/blob/develop/samples/BatchInsertJSON.ts) | Demonstrates how to insert a batch of rows from a JSON file
[BatchInsertParquet.ts](https://github.com/Teradata/nodejs-driver/blob/develop/samples/BatchInsertParquet.ts) | Demonstrates how to insert a batch of rows from a Parquet file
[BatchInsPerf.ts](https://github.com/Teradata/nodejs-driver/blob/develop/samples/BatchInsPerf.ts) | Measures time to insert one million rows
[CancelSleep.ts](https://github.com/Teradata/nodejs-driver/blob/develop/samples/CancelSleep.ts) | Demonstrates how to use the cancel method to interrupt a query
[CharPadding.ts](https://github.com/Teradata/nodejs-driver/blob/develop/samples/CharPadding.ts) | Demonstrates the database's *Character Export Width* behavior
[CommitRollback.ts](https://github.com/Teradata/nodejs-driver/blob/develop/samples/CommitRollback.ts) | Demonstrates commit and rollback methods with auto-commit off.
[DecimalDigits.ts](https://github.com/Teradata/nodejs-driver/blob/develop/samples/DecimalDigits.ts) | Demonstrates how to format decimal.Decimal values.
[DriverDatabaseVersion.ts](https://github.com/Teradata/nodejs-driver/blob/develop/samples/DriverDatabaseVersion.ts) | Displays the driver version and database version
[ElicitFile.ts](https://github.com/Teradata/nodejs-driver/blob/develop/samples/ElicitFile.ts) | Demonstrates C source file upload to create a User-Defined Function (UDF)
[ExecuteRequest.ts](https://github.com/Teradata/nodejs-driver/blob/develop/samples/ExecuteRequest.ts) | Demonstrates how to execute a SQL request and display results
[ExportCSVResult.ts](https://github.com/Teradata/nodejs-driver/blob/develop/samples/ExportCSVResult.ts) | Demonstrates how to export a query result set to a CSV file
[ExportCSVResults.ts](https://github.com/Teradata/nodejs-driver/blob/develop/samples/ExportCSVResults.ts) | Demonstrates how to export multiple query result sets to CSV files
[FakeExportCSVResults.ts](https://github.com/Teradata/nodejs-driver/blob/develop/samples/FakeExportCSVResults.ts) | Demonstrates how to export multiple query result sets with the metadata to CSV files
[FakeResultSetCon.ts](https://github.com/Teradata/nodejs-driver/blob/develop/samples/FakeResultSetCon.ts) | Demonstrates connection parameter for fake result sets
[FakeResultSetEsc.ts](https://github.com/Teradata/nodejs-driver/blob/develop/samples/FakeResultSetEsc.ts) | Demonstrates escape function for fake result sets
[FastExportCSV.ts](https://github.com/Teradata/nodejs-driver/blob/develop/samples/FastExportCSV.ts) | Demonstrates how to FastExport rows from a table to a CSV file
[FastExportTable.ts](https://github.com/Teradata/nodejs-driver/blob/develop/samples/FastExportTable.ts) | Demonstrates how to FastExport rows from a table
[FastLoadBatch.ts](https://github.com/Teradata/nodejs-driver/blob/develop/samples/FastLoadBatch.ts) | Demonstrates how to FastLoad batches of rows
[FastLoadCSV.ts](https://github.com/Teradata/nodejs-driver/blob/develop/samples/FastLoadCSV.ts) | Demonstrates how to FastLoad batches of rows from a CSV file
[FastLoadJSON.ts](https://github.com/Teradata/nodejs-driver/blob/develop/samples/FastLoadJSON.ts) | Demonstrates how to FastLoad batches of rows from a JSON file
[FastLoadParquet.ts](https://github.com/Teradata/nodejs-driver/blob/develop/samples/FastLoadParquet.ts) | Demonstrates how to FastLoad batches of rows from a Parquet file
[HelpSession.ts](https://github.com/Teradata/nodejs-driver/blob/develop/samples/HelpSession.ts) | Displays session information
[IgnoreErrors.ts](https://github.com/Teradata/nodejs-driver/blob/develop/samples/IgnoreErrors.ts) | Demonstrates how to ignore errors
[InsertLob.ts](https://github.com/Teradata/nodejs-driver/blob/develop/samples/InsertLob.ts) | Demonstrates how to insert BLOB and CLOB values
[InsertXML.ts](https://github.com/Teradata/nodejs-driver/blob/develop/samples/InsertXML.ts) | Demonstrates how to insert and retrieve XML values
[LoadCSVFile.ts](https://github.com/Teradata/nodejs-driver/blob/develop/samples/LoadCSVFile.ts) | Demonstrates how to load data from a CSV file into a table
[LobLocators.ts](https://github.com/Teradata/nodejs-driver/blob/develop/samples/LobLocators.ts) | Demonstrates how to use LOB locators
[MetadataFromPrepare.ts](https://github.com/Teradata/nodejs-driver/blob/develop/samples/MetadataFromPrepare.ts) | Demonstrates how to prepare a SQL request and obtain SQL statement metadata
[ParamDataTypes.ts](https://github.com/Teradata/nodejs-driver/blob/develop/samples/ParamDataTypes.ts) | Demonstrates how to specify data types for parameter marker bind values
[ShowCommand.ts](https://github.com/Teradata/nodejs-driver/blob/develop/samples/ShowCommand.ts) | Displays the results from the `SHOW` command
[StoredProc.ts](https://github.com/Teradata/nodejs-driver/blob/develop/samples/StoredProc.ts) | Demonstrates how to create and call a SQL stored procedure
[TJEncryptPassword.ts](https://github.com/Teradata/nodejs-driver/blob/develop/samples/TJEncryptPassword.ts) | Creates encrypted password files
<a id="Using"></a>
### Using the Driver
Your JavaScript program must import the `teradatasql` package in order to use the driver.
const teradatasql = require("teradatasql");
After importing the `teradatasql` package, your JavaScript program calls the `teradatasql.connect` function to open a connection to the database.
const con = teradatasql.connect({
host: "whomooz",
user: "guest",
password: "please"
});
For asynchronous connection establishment, use the `teradatasql.connectAsync` function which returns a Promise:
const con = await teradatasql.connectAsync({
host: "whomooz",
user: "guest",
password: "please"
});
You may specify connection parameters as a JavaScript object, as a JSON string, or using a combination of the two approaches. Both `teradatasql.connect` and `teradatasql.connectAsync` functions accept a JavaScript object as the first argument and an optional JSON string as the second argument.
Connection parameters specified only as a JavaScript object:
con = teradatasql.connect({host:"whomooz",user:"guest",password:"please"});
Connection parameters specified as a JSON string:
con = teradatasql.connect({}, '{"host":"whomooz", "user":"guest", "password":"please"}');
Connection parameters specified using a combination:
con = teradatasql.connect({host:"whomooz"}, '{"user":"guest", "password":"please"}');
The same parameter specification approaches work with `teradatasql.connectAsync`:
con = await teradatasql.connectAsync({host:"whomooz",user:"guest",password:"please"});
When a combination of parameters are specified, connection parameters specified as a JSON string take precedence over same-named connection parameters specified in the JavaScript object.
<a id="AsyncConnectionManagement"></a>
### Async Connection Management
The driver provides non-blocking asynchronous connection operations through the `connectAsync` and `closeAsync` methods, enabling concurrent database operations without blocking the Node.js event loop.
**Important Limitation:** When an async operation is in progress, ALL other operations (both sync and async) are blocked (rejected with specific error codes, not queued) on that connection. This applies to connection operations (`connectAsync`, `closeAsync`) as well as SQL execution operations (`executeAsync`, `executemanyAsync` via cursor). See [Concurrency Behavior and Limitations](#concurrency-behavior-and-limitations) below for details.
#### Overview
Traditional synchronous `connect()` and `close()` methods block the Node.js event loop during database connection establishment and closure. The asynchronous alternatives provide:
* Non-blocking connection establishment and closure
* Improved application responsiveness during connection operations
* Support for concurrent connection operations across multiple database instances
* Full backward compatibility with existing synchronous APIs
#### Asynchronous Connection Establishment
The `connectAsync` method establishes a database connection asynchronously using the `async`/`await` pattern:
```javascript
const teradatasql = require("teradatasql");
async function connectToDatabase() {
const con = new teradatasql.TeradataConnection();
await con.connectAsync({
host: "whomooz",
user: "guest",
password: "please"
});
// Connection is now ready for use
const cursor = con.cursor();
cursor.execute("SELECT * FROM DBC.DBCInfo");
const rows = cursor.fetchall();
console.log(rows);
await con.closeAsync();
}
connectToDatabase().catch(console.error);
```
Like the synchronous `connect` method, `connectAsync` accepts connection parameters as a JavaScript object, a JSON string, or a combination of both:
```javascript
// Parameters as JavaScript object
await con.connectAsync({host:"whomooz", user:"guest", password:"please"});
// Parameters as JSON string
await con.connectAsync({}, '{"host":"whomooz", "user":"guest", "password":"please"}');
// Parameters as combination
await con.connectAsync({host:"whomooz"}, '{"user":"guest", "password":"please"}');
```
#### Timeout Behavior
The `connectAsync` method respects the `logon_timeout` connection parameter with timeout handling.
**Important:** When `logon_timeout` is not specified, it defaults to `"0"` (per driver documentation).
**Two Timeout Scenarios:**
1. **Not specified OR "0"** (default behavior): Uses **5-minute extended timeout**
- When `logon_timeout` is omitted, it defaults to `"0"`
- Honors user intent of "long wait acceptable"
- Provides safety timeout to prevent infinite hangs
- Note: Synchronous `connect()` with default/`"0"` waits indefinitely; asynchronous `connectAsync()` uses 5 minutes as a safety timeout
```javascript
// Not specified (defaults to "0")
await con.connectAsync({
host: "localhost",
user: "dbc",
password: "dbc"
// No logon_timeout -> defaults to "0" -> 5 minute extended timeout
});
// Explicitly set to "0" (same as default)
await con.connectAsync({
host: "localhost",
user: "dbc",
password: "dbc",
logon_timeout: "0" // Explicit "0" -> 5 minute extended timeout
});
```
2. **Positive value specified**: Uses **specified timeout + 5-second buffer**
- Buffer ensures server-side timeout triggers before client-side timeout
- Provides cleaner error messages from database driver
```javascript
await con.connectAsync({
host: "localhost",
user: "dbc",
password: "dbc",
logon_timeout: "60" // 60s server timeout + 5s buffer = 65s client timeout
});
```
**Dual-Layer Timeout Protection:**
- **Server-side**: Go driver's `context.WithTimeout()` governs the actual database connection
- **Client-side**: TypeScript polling loop prevents infinite waiting
- Whichever timeout is shorter takes precedence
#### Asynchronous Connection Closure
The `closeAsync` method closes a database connection asynchronously:
```javascript
await con.closeAsync();
```
#### Concurrency Behavior and Limitations
**Critical Limitation:** When **ANY** asynchronous operation is in progress, **ALL other operations** (both sync and async) are blocked (rejected with specific error codes, not queued) on that connection. This applies to:
- `connectAsync()` / `closeAsync()` / `executeAsync()` / `executemanyAsync()` (via cursor) - When running, blocks ALL operations on that connection
**What This Means:**
- During async operation: Cannot start another async operation OR perform sync operations (Error 801/802/803/804)
- Operations are immediately rejected with error codes, not queued for later execution
- Must wait for async operation to complete before ANY other operation on that connection
**Example of sequential async operations (correct):**
```javascript
const con = new teradatasql.TeradataConnection();
await con.connectAsync({host:"whomooz", user:"guest", password:"please"});
// Perform async SQL execution - wait for completion
const cursor = con.cursor();
await cursor.executeAsync("SELECT * FROM MyTable");
const rows = cursor.fetchall();
cursor.close();
// Now safe to close asynchronously
await con.closeAsync();
```
**Concurrent async operations across different connections are supported:**
```javascript
// This is valid - different connections can have concurrent async operations
const con1 = new teradatasql.TeradataConnection();
const con2 = new teradatasql.TeradataConnection();
await Promise.all([
con1.connectAsync({host:"database1", user:"guest", password:"please"}),
con2.connectAsync({host:"database2", user:"guest", password:"please"})
]);
```
#### Error Handling
The async connection methods provide enhanced error handling with specific error codes. The driver uses a dual-layer validation approach:
- **TypeScript layer (801, 802, 803, 804)**: Primary validation you will typically encounter. Catches operation conflicts at the object level before they reach the Go layer.
- **Go layer (750-752, 760-765)**: Defense-in-depth backup validation. Provides additional safety checks at the native code level.
In normal usage, you will see TypeScript layer errors (801, 802, 803, 804) because they catch conflicts first. Go layer errors (750-752, 760-765) serve as a safety net.
**Error Code Reference:**
#### User-Facing Errors (TypeScript Layer)
**You will typically see these errors** during async operation conflicts. The TypeScript layer validates operations before calling the Go layer.
| Code | Scenario | What's Blocked | What's In Progress |
|------|----------|----------------|-------------------|
| **801** | Same cursor async blocks operations | Any operation on same cursor | executeAsync/executemanyAsync on this cursor |
| **802** | Different cursor async blocks operations | New cursor creation or cursor operations | executeAsync/executemanyAsync on another cursor |
| **803** | Connection async blocks operations | Cursor operations (sync/async) or another connection async | connectAsync/closeAsync |
| **804** | Cursor async blocks connection async | Connection async operations (connectAsync/closeAsync) | executeAsync/executemanyAsync on a cursor |
#### Internal Validation Errors (Go Layer - Defense-in-Depth)
> **Note:** These Go layer errors provide backup validation but are rarely encountered in practice. The TypeScript layer catches operation conflicts first (errors 801, 802, 803, 804). These are documented for completeness and technical transparency.
**SQL Execution Conflict Errors (750-759 range)**
| Error Code | Description | TypeScript Equivalent | Notes |
|------------|-------------|----------------------|-------|
| **750** | SQL request still executing - submit request later | 801 | TypeScript catches first |
| **751** | SQL request still executing - close connection later | 801 | TypeScript catches first |
| **752** | SQL request still executing - close rows later | 801 | TypeScript catches first |
**Async Connection Validation Errors (760-769 range)**
| Error Code | Description | TypeScript Equivalent | Notes |
|------------|-------------|----------------------|-------|
| **760** | Invalid zero connection handle | N/A | Should not occur |
| **761** | Handle not valid or not associated with async operation | N/A | Should not occur |
| **762** | Invalid connection state detected | N/A | Should not occur |
| **763** | Synchronous operation blocked by async operation | 803 | TypeScript catches first |
| **764** | Invalid connection close state detected | N/A | Should not occur |
| **765** | Async connection close in progress - operation blocked | 803 | TypeScript catches first |
All error messages follow this format:
```
[Error <code>] [SQLState HY000] <description>
```
#### Timeout Protection
Both `connectAsync` and `closeAsync` include client-side timeout protection to prevent indefinite polling loops:
**`connectAsync()` Timeout:**
* **When `logon_timeout` not specified or `"0"` (default):** 5 minutes (300 seconds)
* Compromise between honoring "long wait acceptable" intent and preventing infinite hangs
* Note: Synchronous `connect()` waits indefinitely with default/`"0"`, but async operations need safety timeout
* **When `logon_timeout` > 0:** User-specified timeout + 5-second buffer
* Example: `logon_timeout="60"` results in 65-second client-side timeout
* Buffer ensures server-side timeout triggers first for cleaner error messages
**`closeAsync()` Timeout:**
* **Fixed 30-second timeout** for all close operations
* Close operations typically complete quickly, so 30 seconds is generous
**Polling Interval (Both Methods):**
* **100 milliseconds** - How frequently the driver checks operation completion status
**What the Timeout Does:**
The timeout is client-side protection only. It controls how long the TypeScript layer waits for the Go layer to complete the operation, but does not affect the database server timeout. When exceeded, an `OperationalError` is thrown and the connection handle is cleaned up.
#### Migration from Synchronous to Asynchronous
Migrating from synchronous to asynchronous connection methods is straightforward:
**Before (Synchronous):**
```javascript
const con = teradatasql.connect({host:"whomooz", user:"guest", password:"please"});
// ... operations ...
con.close();
```
**After (Asynchronous):**
```javascript
const con = new teradatasql.TeradataConnection();
await con.connectAsync({host:"whomooz", user:"guest", password:"please"});
// ... operations ...
await con.closeAsync();
```
#### Common Pitfalls and Troubleshooting
**Missing await Keywords**
Forgetting `await` causes silent failures. Always await async operations:
```javascript
// Wrong - operation not awaited
con.connectAsync({host:"whomooz", user:"guest", password:"please"});
// Correct
await con.connectAsync({host:"whomooz", user:"guest", password:"please"});
```
**Concurrent Operations on Same Connection**
Error 801, 802, 803, or 804 indicates an async operation is already in progress. Wait for completion before starting another operation:
```javascript
// Wrong - trying to use cursor while async operation executes
cursor1.executeAsync("SELECT * FROM Table1"); // No await - returns immediately
cursor1.fetchall(); // Error 801 - cursor1 async still executing
// Wrong - starting another cursor operation on same connection
const cursor1 = con.cursor();
const cursor2 = con.cursor();
cursor1.executeAsync("SELECT * FROM Table1"); // No await
cursor2.execute("SELECT * FROM Table2"); // Error 802 - cursor1 async still executing
// Correct - sequential operations with proper await
await cursor1.executeAsync("SELECT * FROM Table1");
cursor1.fetchall();
cursor1.close();
await cursor2.executeAsync("SELECT * FROM Table2");
cursor2.fetchall();
cursor2.close();
```
**Connection Not Closed Properly**
Always close connections in finally blocks to prevent resource leaks:
```javascript
const con = new teradatasql.TeradataConnection();
try {
await con.connectAsync({host:"whomooz", user:"guest", password:"please"});
// ... operations ...
} finally {
await con.closeAsync();
}
```
**Timeout Issues**
If connections timeout unexpectedly, check `logon_timeout` parameter. Default `"0"` uses 5-minute timeout for async operations. Specify explicit timeout if needed:
```javascript
await con.connectAsync({
host:"whomooz",
user:"guest",
password:"please",
logon_timeout:"60" // 60 second timeout
});
```
**Error Code Reference**
Common async operation error codes:
- **801**: Cursor async operation in progress - wait for completion
- **802**: Another cursor has async operation - wait for completion
- **803**: Connection async operation in progress - wait for completion
- **804**: Cursor async blocks connection async - wait for completion
- **750-765**: Go layer validation errors - see error message for details
<a id="ConnectionParameters"></a>
### Connection Parameters
The following table lists the connection parameters currently offered by the driver. Connection parameter values are case-sensitive unless stated otherwise.
Our goal is consistency for the connection parameters offered by this driver and the Teradata JDBC Driver, with respect to connection parameter names and functionality. For comparison, Teradata JDBC Driver connection parameters are [documented here](https://downloads.teradata.com/doc/connectivity/jdbc/reference/current/jdbcug_chapter_2.html#BGBHDDGB).
Parameter | Default | Type | Description
----------------------- | ----------- | -------------- | ---
`account` | | string | <a id="cp_account"></a> Specifies the database account. Equivalent to the Teradata JDBC Driver `ACCOUNT` connection parameter.
`browser` | | string | <a id="cp_browser"></a> Specifies the command to open the browser for Browser Authentication when `logmech` is `BROWSER`. Browser Authentication is supported for Windows and macOS. Equivalent to the Teradata JDBC Driver `BROWSER` connection parameter.<br/>The specified command must include a placeholder token, literally specified as `PLACEHOLDER`, which the driver will replace with the Identity Provider authorization endpoint URL. The `PLACEHOLDER` token is case-sensitive and must be specified in uppercase.<br/>• On Windows, the default command is `cmd /c start "title" "PLACEHOLDER"`. Windows command syntax requires the quoted title to precede the quoted URL.<br/>• On macOS, the default command is `open PLACEHOLDER`. macOS command syntax does not allow the URL to be quoted.
`browser_tab_timeout` | `"5"` | quoted integer | <a id="cp_browser_tab_timeout"></a> Specifies the number of seconds to wait before closing the browser tab after Browser Authentication is completed. The default is 5 seconds. The behavior is under the browser's control, and not all browsers support automatic closing of browser tabs. Typically, the tab used to log on will remain open indefinitely, but the second and subsequent tabs will be automatically closed. Specify `0` (zero) to close the tab immediately. Specify `-1` to turn off automatic closing of browser tabs. Browser Authentication is supported for Windows and macOS. Equivalent to the Teradata JDBC Driver `BROWSER_TAB_TIMEOUT` connection parameter.
`browser_timeout` | `"180"` | quoted integer | <a id="cp_browser_timeout"></a> Specifies the number of seconds that the driver will wait for Browser Authentication to complete. The default is 180 seconds (3 minutes). Browser Authentication is supported for Windows and macOS. Equivalent to the Teradata JDBC Driver `BROWSER_TIMEOUT` connection parameter.
`code_append_file` | `"-out"` | string | <a id="cp_code_append_file"></a> Specifies how to display the verification URL and code. Optional when `logmech` is `CODE` and ignored for other `logmech` values. The default `-out` prints the verification URL and code to stdout. Specify `-err` to print the verification URL and code to stderr. Specify a file name to append the verification URL and code to an existing file or create a new file if the file does not exist. Equivalent to the Teradata JDBC Driver `CODE_APPEND_FILE` connection parameter.
`column_name` | `"false"` | quoted boolean | <a id="cp_column_name"></a> Controls the behavior of cursor `.description` sequence `name` items. Equivalent to the Teradata JDBC Driver `COLUMN_NAME` connection parameter. False specifies that a cursor `.description` sequence `name` item provides the AS-clause name if available, or the column name if available, or the column title. True specifies that a cursor `.description` sequence `name` item provides the column name if available, but has no effect when StatementInfo parcel support is unavailable.
`concurrent_interval` | `"1000"` | quoted integer | <a id="cp_concurrent_interval"></a> Specifies the interval in milliseconds for Laddered Concurrent Connect (LCC) to wait before starting another concurrent connection attempt.
`concurrent_limit` | `"3"` | quoted integer | <a id="cp_concurrent_limit"></a> Limits the number of concurrent connection attempts.
`connect_failure_ttl` | `"0"` | quoted integer | <a id="cp_connect_failure_ttl"></a> Specifies the time-to-live in seconds to remember the most recent connection failure for each IP address/port combination. The driver subsequently skips connection attempts to that IP address/port for the duration of the time-to-live. The default value of zero disables this feature. The recommended value is half the database restart time. Equivalent to the Teradata JDBC Driver `CONNECT_FAILURE_TTL` connection parameter.
`connect_function` | `"0"` | quoted integer | <a id="cp_connect_function"></a> Specifies whether the database should allocate a Logon Sequence Number (LSN) for this session, or associate this session with an existing LSN. Specify `0` for a session with no LSN (the default). Specify `1` to allocate a new LSN for the session. Specify `2` to associate the session with the existing LSN identified by the `logon_sequence_number` connection parameter. The database only permits sessions for the same user to share an LSN. Equivalent to the Teradata JDBC Driver `CONNECT_FUNCTION` connection parameter.
`connect_timeout` | `"10000"` | quoted integer | <a id="cp_connect_timeout"></a> Specifies the timeout in milliseconds for establishing a TCP socket connection. Specify `0` for no timeout. The default is 10 seconds (10000 milliseconds).
`cop` | `"true"` | quoted boolean | <a id="cp_cop"></a> Specifies whether COP Discovery is performed. Equivalent to the Teradata JDBC Driver `COP` connection parameter.
`coplast` | `"false"` | quoted boolean | <a id="cp_coplast"></a> Specifies how COP Discovery determines the last COP hostname. Equivalent to the Teradata JDBC Driver `COPLAST` connection parameter. When `coplast` is `false` or omitted, or COP Discovery is turned off, then no DNS lookup occurs for the coplast hostname. When `coplast` is `true`, and COP Discovery is turned on, then a DNS lookup occurs for a coplast hostname.
`database` | | string | <a id="cp_database"></a> Specifies the initial database to use after logon, instead of the user's default database. Equivalent to the Teradata JDBC Driver `DATABASE` connection parameter.
`dbs_port` | `"1025"` | quoted integer | <a id="cp_dbs_port"></a> Specifies the database port number. Equivalent to the Teradata JDBC Driver `DBS_PORT` connection parameter.
`encryptdata` | `"false"` | quoted boolean | <a id="cp_encryptdata"></a> Controls encryption of data exchanged between the driver and the database. Equivalent to the Teradata JDBC Driver `ENCRYPTDATA` connection parameter.
`error_query_count` | `"21"` | quoted integer | <a id="cp_error_query_count"></a> Specifies how many times the driver will attempt to query FastLoad Error Table 1 after a FastLoad operation. Equivalent to the Teradata JDBC Driver `ERROR_QUERY_COUNT` connection parameter.
`error_query_interval` | `"500"` | quoted integer | <a id="cp_error_query_interval"></a> Specifies how many milliseconds the driver will wait between attempts to query FastLoad Error Table 1. Equivalent to the Teradata JDBC Driver `ERROR_QUERY_INTERVAL` connection parameter.
`error_table_1_suffix` | `"_ERR_1"` | string | <a id="cp_error_table_1_suffix"></a> Specifies the suffix for the name of FastLoad Error Table 1. Equivalent to the Teradata JDBC Driver `ERROR_TABLE_1_SUFFIX` connection parameter.
`error_table_2_suffix` | `"_ERR_2"` | string | <a id="cp_error_table_2_suffix"></a> Specifies the suffix for the name of FastLoad Error Table 2. Equivalent to the Teradata JDBC Driver `ERROR_TABLE_2_SUFFIX` connection parameter.
`error_table_database` | | string | <a id="cp_error_table_database"></a> Specifies the database name for the FastLoad error tables. By default, FastLoad error tables reside in the same database as the destination table being loaded. Equivalent to the Teradata JDBC Driver `ERROR_TABLE_DATABASE` connection parameter.
`fake_result_sets` | `"false"` | quoted boolean | <a id="cp_fake_result_sets"></a> Controls whether a fake result set containing statement metadata precedes each real result set.
`field_quote` | `"\""` | string | <a id="cp_field_quote"></a> Specifies a single character string used to quote fields in a CSV file.
`field_sep` | `","` | string | <a id="cp_field_sep"></a> Specifies a single character string used to separate fields in a CSV file. Equivalent to the Teradata JDBC Driver `FIELD_SEP` connection parameter.
`gateway_deadline` | `"50"` | quoted integer | <a id="cp_gateway_deadline"></a> Specifies the Gateway deadline in seconds. The driver automatically closes and re-establishes the database socket connection if the OpenID Connect (OIDC) flow takes longer than this. Should be smaller than the Gateway's denial-of-service protection timeout: `gtwcontrol` setting "connection timeout in seconds" with default 60 seconds. Equivalent to the Teradata JDBC Driver `GATEWAY_DEADLINE` connection parameter.
`govern` | `"true"` | quoted boolean | <a id="cp_govern"></a> Controls FastLoad and FastExport throttling by Teradata workload management rules. When set to `true` (the default), workload management rules may delay a FastLoad or FastExport. When set to `false`, workload management rules will reject rather than delay a FastLoad or FastExport. Equivalent to the Teradata JDBC Driver `GOVERN` connection parameter.
`host` | | string | <a id="cp_host"></a> Specifies the database hostname.
`http_proxy` | | string | <a id="cp_http_proxy"></a> Specifies the proxy server URL for HTTP connections to TLS certificate verification CRL and OCSP endpoints. The URL must begin with `http://` and must include a colon `:` and port number.
`http_proxy_password` | | string | <a id="cp_http_proxy_password"></a> Specifies the proxy server password for the proxy server identified by the `http_proxy` parameter. This parameter may only be specified in conjunction with the `http_proxy` parameter. When this parameter is omitted, no proxy server password is provided to the proxy server identified by the `http_proxy` parameter.
`http_proxy_user` | | string | <a id="cp_http_proxy_user"></a> Specifies the proxy server username for the proxy server identified by the `http_proxy` parameter. This parameter may only be specified in conjunction with the `http_proxy` parameter. When this parameter is omitted, no proxy server username is provided to the proxy server identified by the `http_proxy` parameter.
`https_port` | `"443"` | quoted integer | <a id="cp_https_port"></a> Specifies the database port number for HTTPS/TLS connections. Equivalent to the Teradata JDBC Driver `HTTPS_PORT` connection parameter.
`https_proxy` | | string | <a id="cp_https_proxy"></a> Specifies the proxy server URL for HTTPS/TLS connections to the database and to Identity Provider endpoints. The URL must begin with `http://` and must include a colon `:` and port number. The driver connects to the proxy server using a non-TLS HTTP connection, then uses the HTTP CONNECT method to establish an HTTPS/TLS connection to the destination. Equivalent to the Teradata JDBC Driver `HTTPS_PROXY` connection parameter.
`https_proxy_password` | | string | <a id="cp_https_proxy_password"></a> Specifies the proxy server password for the proxy server identified by the `https_proxy` parameter. This parameter may only be specified in conjunction with the `https_proxy` parameter. When this parameter is omitted, no proxy server password is provided to the proxy server identified by the `https_proxy` parameter. Equivalent to the Teradata JDBC Driver `HTTPS_PROXY_PASSWORD` connection parameter.
`https_proxy_user` | | string | <a id="cp_https_proxy_user"></a> Specifies the proxy server username for the proxy server identified by the `https_proxy` parameter. This parameter may only be specified in conjunction with the `https_proxy` parameter. When this parameter is omitted, no proxy server username is provided to the proxy server identified by the `https_proxy` parameter. Equivalent to the Teradata JDBC Driver `HTTPS_PROXY_USER` connection parameter.
`https_retry` | `"2"` | quoted integer | <a id="cp_https_retry"></a> Specifies the number of HTTPS connection retries for a single-node database. Specify `0` (zero) to turn off HTTPS connection retries. Equivalent to the Teradata JDBC Driver `HTTPS_RETRY` connection parameter.
`jws_algorithm` | `"RS256"` | string | <a id="cp_jws_algorithm"></a> Specifies the JSON Web Signature (JWS) algorithm to sign the JWT Bearer Token for client authentication. Optional when `logmech` is `BEARER` and ignored for other `logmech` values. The default `RS256` is RSASSA-PKCS1-v1_5 using SHA-256. Specify `RS384` for RSASSA-PKCS1-v1_5 using SHA-384. Specify `RS512` for RSASSA-PKCS1-v1_5 using SHA-512. Equivalent to the Teradata JDBC Driver `JWS_ALGORITHM` connection parameter.
`jws_audience` | | string | <a id="cp_jws_audience"></a> Specifies the JWT Bearer Token audience claim for client authentication. Optional when `logmech` is `BEARER` and ignored for other `logmech` values. The default is the Identity Provider token endpoint URL. Equivalent to the Teradata JDBC Driver `JWS_AUDIENCE` connection parameter.
`jws_cert` | | string | <a id="cp_jws_cert"></a> Specifies the file name of the X.509 certificate PEM file that contains the public key corresponding to the private key from `jws_private_key`. Optional when `logmech` is `BEARER` and ignored for other `logmech` values. When this parameter is specified, the "x5t" header thumbprint is added to the JWT Bearer Token for the Identity Provider to select the public key for JWT signature verification. Some Identity Providers, such as Microsoft Entra ID, require this. When this parameter is omitted, the "x5t" header thumbprint is not added to the JWT Bearer Token. Some Identity Providers do not require the "x5t" header thumbprint. Equivalent to the Teradata JDBC Driver `JWS_CERT` connection parameter.
`jws_private_key` | | string | <a id="cp_jws_private_key"></a> Specifies the file name of the PEM or JWK file containing the private key to sign the JWT Bearer Token for client authentication. Required when `logmech` is `BEARER` and ignored for other `logmech` values. PEM and JWK file formats are supported. The private key filename must end with the `.pem` or `.jwk` extension. A PEM file must contain the BEGIN/END PRIVATE KEY header and trailer. If a JWK file contains a "kid" (key identifier) parameter, the "kid" header is added to the JWT Bearer Token for the Identity Provider to select the public key for JWT signature verification. Equivalent to the Teradata JDBC Driver `JWS_PRIVATE_KEY` connection parameter.
`lob_support` | `"true"` | quoted boolean | <a id="cp_lob_support"></a> Controls LOB support. Equivalent to the Teradata JDBC Driver `LOB_SUPPORT` connection parameter.
`local_catalog` | `"false"` | quoted boolean | <a id="cp_local_catalog"></a> Controls the catalog name of local objects in result set metadata and parameter metadata. When set to `true` and Virtual System Dictionary (VSD) is available, local objects have the `TD_LOCAL` catalog name. Otherwise, local objects have an empty string for catalog name. This parameter does not affect the catalog name of Open Table Format (OTF) objects, which always have DataLake name as catalog name. Equivalent to the Teradata JDBC Driver `LOCAL_CATALOG` connection parameter.
`log` | `"0"` | quoted integer | <a id="cp_log"></a> Controls debug logging. Somewhat equivalent to the Teradata JDBC Driver `LOG` connection parameter. This parameter's behavior is subject to change in the future. This parameter's value is currently defined as an integer in which the 1-bit governs function and method tracing, the 2-bit governs debug logging, the 4-bit governs transmit and receive message hex dumps, and the 8-bit governs timing. Compose the value by adding together 1, 2, 4, and/or 8.
`logdata` | | string | <a id="cp_logdata"></a> Specifies extra data for the chosen logon authentication method. Equivalent to the Teradata JDBC Driver `LOGDATA` connection parameter.
`logmech` | `"TD2"` | string | <a id="cp_logmech"></a> Specifies the [logon authentication method](#LogonMethods). Equivalent to the Teradata JDBC Driver `LOGMECH` connection parameter. The database user must have the "logon with null password" permission for `KRB5` Single Sign On (SSO) or any of the [OpenID Connect (OIDC)](https://en.wikipedia.org/wiki/OpenID#OpenID_Connect_(OIDC)) methods `BEARER`, `BROWSER`, `CODE`, `CRED`, `JWT`, `ROPC`, or `SECRET`. [GSS-API](https://en.wikipedia.org/wiki/Generic_Security_Services_Application_Program_Interface) methods are `KRB5`, `LDAP`, `TD2`, and `TDNEGO`. Values are case-insensitive.<br/>• `BEARER` uses OIDC Client Credentials Grant with JWT Bearer Token for client authentication.<br/>• `BROWSER` uses Browser Authentication, supported for Windows and macOS.<br/>• `CODE` uses OIDC Device Code Flow, also known as OIDC Device Authorization Grant.<br/>• `CRED` uses OIDC Client Credentials Grant with client_secret_post for client authentication.<br/>• `JWT` uses JSON Web Token.<br/>• `KRB5` uses Kerberos V5.<br/>• `LDAP` uses Lightweight Directory Access Protocol.<br/>• `ROPC` uses OIDC Resource Owner Password Credentials (ROPC).<br/>• `SECRET` uses OIDC Client Credentials Grant with client_secret_basic for client authentication.<br/>• `TD2` uses Teradata Method 2.<br/>• `TDNEGO` automatically selects an appropriate GSS-API logon authentication method. OIDC methods are not selected.
`logon_sequence_number` | | quoted integer | <a id="cp_logon_sequence_number"></a> Associates this session with an existing Logon Sequence Number (LSN) when `connect_function` is `2`. The database only permits sessions for the same user to share an LSN. An LSN groups multiple sessions together for workload management. Using an LSN is a three-step process. First, establish a control session with `connect_function` as `1`, which allocates a new LSN. Second, obtain the LSN from the control session using the escape function `{fn teradata_logon_sequence_number}`. Third, establish an associated session with `connect_function` as `2` and the logon sequence number. Equivalent to the Teradata JDBC Driver `LOGON_SEQUENCE_NUMBER` connection parameter.
`logon_timeout` | `"0"` | quoted integer | <a id="cp_logon_timeout"></a> Specifies the logon timeout in seconds. Zero means no timeout. Equivalent to the Teradata JDBC Driver `LOGON_TIMEOUT` connection parameter.
`manage_error_tables` | `"true"` | quoted boolean | <a id="cp_manage_error_tables"></a> Controls whether the driver manages the FastLoad error tables.
`max_message_body` | `"2097000"` | quoted integer | <a id="cp_max_message_body"></a> Specifies the maximum Response Message size in bytes. Equivalent to the Teradata JDBC Driver `MAX_MESSAGE_BODY` connection parameter.
`oauth_level` | `"0"` | quoted integer | <a id="cp_oauth_level"></a> Controls Single Sign On (SSO) access to Open Table Format (OTF) catalog and storage instances. Equivalent to the Teradata JDBC Driver `OAUTH_LEVEL` connection parameter. If `redrive` is `1` or higher and the database supports Control Data, this specifies which tokens are transmitted to the database with each request, and the database may use the tokens for SSO access to OTF catalog and storage instances. If `redrive` is `0` or the database does not support Control Data, tokens are not transmitted to the database with each request, and tokens will not be available for SSO access