> ## Documentation Index
> Fetch the complete documentation index at: https://cockroachlabs.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Use IntelliJ IDEA with CockroachDB

export const InternalLink = ({version, path = "", children, ...props}) => {
  let detectedVersion = version || "stable";
  if (typeof window !== 'undefined' && !version) {
    const match = window.location.pathname.match(/\/docs\/([^/]+)/);
    if (match) {
      detectedVersion = match[1];
    }
  }
  const normalizedPath = path.startsWith("/") ? path.slice(1) : path;
  return <a href={`/docs/${detectedVersion}/${normalizedPath}`} {...props}>
      {children}
    </a>;
};

You can use CockroachDB in [IntelliJ IDEA](https://www.jetbrains.com/idea) as a [database data source](https://www.jetbrains.com/help/idea/managing-data-sources#data_sources), which lets you accomplish tasks like managing your database's schema from within your IDE.

## Support

As of CockroachDB v24.3, IntelliJ IDEA only has **partial support**. This means that the application is mostly functional, but its integration still has a few rough edges.

### Versions

The level of support in this document was tested as of the following versions:

* CockroachDB v19.1.0-beta.20190225
* IntelliJ IDEA Ultimate 18.1.3
* PostgreSQL JDBC 41.1

<Note>
  This feature should also work with other JetBrains IDEs, such as PyCharm, but Cockroach Labs has not yet tested its integration.
</Note>

### Warnings and errors

Users can expect to encounter the following behaviors when using CockroachDB within IntelliJ IDEA.

* **Warnings** do not require any action on the user's end and can be ignored. Note that even if a message indicates that it is an "error", it can still be treated as a warning by this definition.
* **Errors** require the user to take action to resolve the problem and cannot be ignored.

#### Warnings

##### \[XXUUU] ERROR: could not decorrelate subquery

<img src="https://mintcdn.com/cockroachlabs/8_H4KrPlYfe30hE8/images/common/intellij/XX000_error_could_not_decorrelate_subquery.png?fit=max&auto=format&n=8_H4KrPlYfe30hE8&q=85&s=55a64326f6617547aee2303637b737f0" alt="DBeaver - Select CockroachDB" width="362" height="65" data-path="images/common/intellij/XX000_error_could_not_decorrelate_subquery.png" />

Displays once per load of schema.

***

##### \[42883] ERROR: unknown function: pg\_function\_is\_visible() Failed to retrieve

<img src="https://mintcdn.com/cockroachlabs/8_H4KrPlYfe30hE8/images/common/intellij/42883_error_pg_function_is_visible.png?fit=max&auto=format&n=8_H4KrPlYfe30hE8&q=85&s=ef341b6549f722b4b8b9fdee9d0bf2db" alt="DBeaver - Select CockroachDB" width="361" height="66" data-path="images/common/intellij/42883_error_pg_function_is_visible.png" />

Display periodically. Does not impact functionality.

#### Errors

##### \[42703] org.postgresql.util.PSQLException: ERROR: column "n.xmin" does not exist

<img src="https://mintcdn.com/cockroachlabs/8_H4KrPlYfe30hE8/images/common/intellij/42073_error_column_n_xmin_does_not_exist.png?fit=max&auto=format&n=8_H4KrPlYfe30hE8&q=85&s=07055fb616a044a9ae4e75d69f842d95" alt="DBeaver - Select CockroachDB" width="362" height="64" data-path="images/common/intellij/42073_error_column_n_xmin_does_not_exist.png" />

Requires setting **Introspect using JDBC metadata** ([details below](#set-cockroachdb-as-a-data-source-in-intellij)).

***

## Set CockroachDB as a data source in IntelliJ

1. Launch the **Database** tool window. ( **View** > **Tool Windows** > **Database** )<img src="https://mintcdn.com/cockroachlabs/8_H4KrPlYfe30hE8/images/common/intellij/01_database_tool_window.png?fit=max&auto=format&n=8_H4KrPlYfe30hE8&q=85&s=bc8fd1c83d89d17642959cb92dc71d56" alt="DBeaver - Select CockroachDB" width="519" height="340" data-path="images/common/intellij/01_database_tool_window.png" />
2. Add a PostgreSQL data source. ( **New (+)** > **Data Source** > **PostgreSQL** )<img src="https://mintcdn.com/cockroachlabs/8_H4KrPlYfe30hE8/images/common/intellij/02_postgresql_data_source.png?fit=max&auto=format&n=8_H4KrPlYfe30hE8&q=85&s=7c4912548cb8afb136d28bebc0be1178" alt="DBeaver - Select CockroachDB" width="396" height="313" data-path="images/common/intellij/02_postgresql_data_source.png" />
3. On the **General** tab, enter your database's connection string:

| Field        | Value                                                                                                                                                                                                                                    |
| ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Host**     | Your CockroachDB cluster's hostname                                                                                                                                                                                                      |
| **Port**     | Your CockroachDB cluster's port. By default, CockroachDB uses port **26257**.                                                                                                                                                            |
| **Database** | The database you want to connect to. Note that CockroachDB's notion of database differs from PostgreSQL's; you can see your cluster's databases through the <InternalLink path="show-databases">`SHOW DATABASES`</InternalLink> command. |
| **User**     | The user to connect as. By default, you can use **root**.                                                                                                                                                                                |
| **Password** | If your cluster uses password authentication, enter the password.                                                                                                                                                                        |
| **Driver**   | Select or install **PostgreSQL** using a version greater than or equal to 41.1. (Older drivers have not been tested.)                                                                                                                    |

<img src="https://mintcdn.com/cockroachlabs/8_H4KrPlYfe30hE8/images/common/intellij/03_general_tab.png?fit=max&auto=format&n=8_H4KrPlYfe30hE8&q=85&s=d2f826d33e0c6912379bf322492cf723" alt="DBeaver - Select CockroachDB" width="560" height="309" data-path="images/common/intellij/03_general_tab.png" />

4. Install or select a **PostgreSQL** driver. We recommend a version greater than or equal to 41.1.
5. If your cluster uses SSL authentication, go to the **SSH/SSL** tab, select **Use SSL** and provide the location of your certificate files.
6. Go to the **Options** tab, and then select **Introspect using JDBC metadata**.<img src="https://mintcdn.com/cockroachlabs/8_H4KrPlYfe30hE8/images/common/intellij/04_options_tab.png?fit=max&auto=format&n=8_H4KrPlYfe30hE8&q=85&s=3a20829dd9b6cddd09f169d30752d237" alt="DBeaver - Select CockroachDB" width="559" height="192" data-path="images/common/intellij/04_options_tab.png" />
7. Click **OK**.

You can now use IntelliJ's [database tool window](https://www.jetbrains.com/help/idea/working-with-the-database-tool-window) to interact with your CockroachDB cluster.

## Report issues with IntelliJ IDEA & CockroachDB

If you encounter issues other than those outlined above, please <InternalLink path="support-resources">contact Support</InternalLink> with the following details about the environment where you encountered the issue:

* CockroachDB version ( <InternalLink path="cockroach-version">`cockroach version`</InternalLink> )
* IntelliJ IDEA version
* Operating system
* Steps to reproduce the behavior
* If possible, a trace of the SQL statements sent to CockroachDB while the error is being reproduced using <InternalLink path="logging-use-cases#sql_exec">SQL query logging</InternalLink>.

## See also

* <InternalLink path="connection-parameters">Client connection parameters</InternalLink>
* <InternalLink path="third-party-database-tools">Third-Party Database Tools</InternalLink>
