The Guide for Time Series Data Projects is out.

Download now
Skip to content

How to Connect with Java

Effortlessly connect Java applications with CrateDB using JDBC driver.


The CrateDB JDBC driver, built upon the PostgreSQL JDBC Driver, facilitates seamless interaction between Java applications and CrateDB versions 0.38.0 and newer. This JDBC Type 4 driver, compliant with JDBC 4.1 specifications, is entirely written in Java and communicates with the database using the PostgreSQL Wire Protocol


import java.sql.*;
import java.util.Properties;

public class Main {
    public static void main(String[] args) {
        try {
            Properties properties = new Properties();
            properties.put("user", "admin");
            properties.put("password", "");
            properties.put("ssl", true);
            Connection conn = DriverManager.getConnection(

            Statement statement = conn.createStatement();
            ResultSet resultSet = statement.executeQuery("SELECT name FROM sys.cluster");
            String name = resultSet.getString("name");

        } catch (SQLException e) {

The CrateDB JDBC driver's primary function involves establishing connections, enabling the execution of SQL queries, and facilitating the retrieval of query results within the CrateDB database. The driver acts as a bridge for Java applications, ensuring standardized and reliable data access while aligning with JDBC standards for compatibility and reliability in data transmission. For detailed technical specifications and comprehensive functionalities, refer to the CrateDB JDBC Driver documentation.

Additional resources