Documentation Index
Fetch the complete documentation index at: https://mintlify.com/questdb/questdb/llms.txt
Use this file to discover all available pages before exploring further.
The QuestDB Java client provides a high-performance API for ingesting data using the InfluxDB Line Protocol.
Installation
<dependency>
<groupId>org.questdb</groupId>
<artifactId>questdb</artifactId>
<version>9.3.3</version>
</dependency>
Quick start
import io.questdb.client.Sender;
import java.time.Instant;
public class Example {
public static void main(String[] args) {
try (Sender sender = Sender.builder()
.address("localhost:9009")
.build()) {
sender.table("trades")
.symbol("symbol", "ETH-USD")
.symbol("side", "sell")
.doubleColumn("price", 2615.54)
.doubleColumn("amount", 0.00044)
.atNow();
sender.flush();
}
}
}
Configuration
Sender sender = Sender.builder()
.address("localhost:9009")
.enableAuth("admin")
.authToken("your-token")
.bufferCapacity(128 * 1024) // 128KB
.build();
Builder options
Server address in format host:port
Buffer size in bytes (default: 64KB)
Enable authentication with key ID
Authentication token (private key)
Data types
sender.table("sensors")
.symbol("location", "warehouse-1") // Symbol
.longColumn("sensor_id", 12345) // Long
.doubleColumn("temperature", 23.5) // Double
.stringColumn("status", "active") // String
.booleanColumn("is_online", true) // Boolean
.timestampColumn("timestamp", Instant.now()) // Timestamp
.atNow(); // Use server timestamp
Best practices
Use try-with-resources to ensure proper cleanup of sender resources.
try (Sender sender = Sender.builder().address("localhost:9009").build()) {
// Batch multiple rows
for (int i = 0; i < 1000; i++) {
sender.table("metrics")
.symbol("host", "server-" + i)
.doubleColumn("cpu", Math.random() * 100)
.atNow();
}
sender.flush();
}
Error handling
try (Sender sender = Sender.builder().address("localhost:9009").build()) {
sender.table("trades")
.symbol("symbol", "BTC-USD")
.doubleColumn("price", 50000.0)
.atNow();
sender.flush();
} catch (Exception e) {
System.err.println("Failed to send data: " + e.getMessage());
}
- Batch rows: Send multiple rows before calling
flush()
- Reuse sender: Create once, use for entire application lifecycle
- Use symbols: Convert low-cardinality strings to symbols
- Async flush: Consider implementing async flushing for higher throughput
Next steps
ILP Reference
Learn more about the protocol
Examples
Browse code examples