Skip to main content

On This Page

Introduction to IoTDB

2 min read
Share

These articles are AI-generated summaries. Please check the original sources for full details.

Introduction to IoTDB

Apache IoTDB is a free, open-source database specifically engineered for time-series data, with a focus on supporting Internet of Things (IoT) devices but applicable to any timestamped metric series. It provides SQL compatibility, simplifying integration with existing applications and simplifying data analysis.

IoTDB addresses the challenges of managing high-volume, rapidly changing data from IoT sensors, unlike traditional relational databases optimized for transactional consistency. Failures in such systems can lead to data loss and costly downtime, especially when dealing with mission-critical sensor data.

Key Insights

  • Docker Compose files simplify IoTDB setup: Apache provides readily available files for standalone and clustered deployments.
  • Aligned Time Series improve query efficiency: Allows for querying multiple related sensors as a single unit, reducing query complexity.
  • JDBC Driver support: Enables integration with Java-based applications utilizing standard JDBC interfaces.

Working Example

import java.sql.*;
import java.time.Instant;

public class IoTDBExample {

    public static void main(String[] args) {
        try {
            Class.forName("org.apache.iotdb.jdbc.IoTDBDriver");
            try (Connection con = DriverManager
                .getConnection("jdbc:iotdb://127.0.0.1:6667/", "root", "root")) {

                try (PreparedStatement stmt = con.prepareStatement("INSERT INTO root.baeldung.turbine.device1(timestamp, speed) VALUES (?, ?)")) {
                    stmt.setObject(1, Instant.now().toEpochMilli());
                    stmt.setObject(2, 10);
                    stmt.executeUpdate();
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Practical Applications

  • Smart Manufacturing: Monitoring sensor data from factory equipment to predict maintenance needs and optimize production.
  • Pitfall: Incorrectly modelling data as non-aligned time series when data is inherently correlated, leading to inefficient queries and increased storage costs.

References:

Continue reading

Next article

Joining Tables Without Relation Using JPA Criteria

Related Content