Explore
Connect Your Application
Java
- 1. Choose Scenario
- 2. Get Ready
- 3. Run CrateDB
- 4. Import Data
- 5. Explore Queries
- 6. More Queries
- 7. Connect
- 8. Next Steps
Basic CrateDB connectivity
Crate can use any PostgreSQL-compatible JDBC driver. An example connection string is:
jdbc:postgresql://<host>:5432/doc//
Sample Java application

See a working CrateDB/JDBC example on GitHub →
This is a Java/JDBC load generator that connects to a CrateDB cluster over the PostgreSQL wire protocol and runs a configurable mix of queries against German climate and region data. It assumes you have loaded the data.
The single application class is QueryCrate.
The QueryCrate Java class
Here is what the class does:
- Opens a JDBC connection to a CrateDB cluster.
- Prints the cluster name (
SELECT name FROM sys.cluster) as a connectivity smoke test. - Pre-loads reference data from the database (only for query types that will be run):
- WKT queries: loads every distinct
geo_locationand timestamp fromdemo.climate_data. - REGION queries: loads every
region_namefromdemo.german_regions.
- WKT queries: loads every distinct
- Runs a workload of queries at a configurable rate, choosing from three query types:
- WKT — geo-proximity query: finds min/max temperature within 1 metre of a random point at a random timestamp.
- REGION — three-table join: finds the latest temperature readings for every sensor location inside a named German region, converting Kelvin to Celsius.
- FTS — full-text search: searches the economics column of demo.german_regions using CrateDB's MATCH predicate and returns the top 3 results by relevance score.
- Records the round-trip latency of each query in an HdrHistogram and prints percentile summaries when the run finishes.