# RJDBC

HeavyDB supports the R language using [RJDBC](https://www.rforge.net/RJDBC).

## Examples

### Local Host Example

```
library(RJDBC)
drv <- JDBC("com.heavyai.jdbc.HeavyAIDriver",
            "/home/heavyai/bin/heavyai-utility-6.0.jar",
            identifier.quote="'")
conn <- dbConnect(drv, "jdbc:heavyai:localhost:6274:heavyai", "admin", "HyperInteractive")
dbGetQuery(conn, "SELECT i1 FROM test1  LIMIT 11")
dbGetQuery(conn, "SELECT dep_timestamp FROM flights_2008_10k  LIMIT 11")
```

### Remote Host Example

```
library(RJDBC)
drv <- JDBC("com.heavyai.jdbc.HeavyAIDriver",
            "/home/heavyai/bin/heavyai-utility-6.0.jar",
            identifier.quote="'")
conn <- dbConnect(drv,
                  "jdbc:heavyai:colossus.heavyai.com:6274:heavyai",
                  "admin",
                  "HyperInteractive")
dbGetQuery(conn,
  paste("SELECT date_trunc(month, taxi_weather_tracts_factual.pickup_datetime)",
        "  as key0,",
        "AVG(CASE WHEN 'Hyatt' = ANY",
        "    taxi_weather_tracts_factual.dropoff_store_chains THEN 1 ELSE 0 END)",
        "  AS series_1",
        "FROM taxi_weather_tracts_factual",
        "WHERE (taxi_weather_tracts_factual.dropoff_merc_x >= -8254165.98668337",
        "  AND taxi_weather_tracts_factual.dropoff_merc_x < -8218688.304677745)",
        "AND (taxi_weather_tracts_factual.dropoff_merc_y >= 4966267.65475399",
        "  AND taxi_weather_tracts_factual.dropoff_merc_y < 4989291.122013792)",
        "AND (",
        "  taxi_weather_tracts_factual.pickup_datetime",
        "    >= TIMESTAMP(0) '2009-12-20 08:13:47'",
        "  AND taxi_weather_tracts_factual.pickup_datetime",
        "    < TIMESTAMP(0) '2015-12-31 23:59:59')",
        "GROUP BY key0 ORDER BY key0", sep=" "))
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.heavy.ai/v8.3.0/apis-and-interfaces/rjdbc.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
