跳转到内容

Connect to a database

此内容尚不支持你的语言。

A connection names a database server or file, the user and how to reach it. Connections belong to the project; their passwords never do: they stay in the system keychain. Connections with passwords in the keychain, TLS and SSH tunnels: Works.

  • A server or a file. For a server: host, port, database name and a user with a password. For SQLite or DuckDB: the database file, or a folder to create one in.
  • A keychain. On macOS the login keychain, on Windows the Credential Manager, on Linux a running Secret Service (GNOME Keyring or KWallet). Without one, Ferris IDEA refuses to save a password rather than write it to a file.
  • For Oracle only: Oracle Instant Client, installed by you. Every other built-in driver ships inside Ferris IDEA; nothing is downloaded when you connect.
  1. Open the Database tool window from the stripe on the right.
  2. Click + (New Data Source…) in its toolbar, or press ⌘N (CtrlN) in the tree. You can also right-click the tree and choose New › Data Source…. The New Connection dialog opens on its General page.
  3. Choose the System. Type to filter the list by name; ↑ ↓ and ↩ pick one. The line below the list says how well that system is tested, for example “Tested with 18.6” for PostgreSQL or “Beta: Ferris IDEA has not tested this system against a server”.
  4. Give it a Name, then fill Host, Port, Database and User. An empty port means the system’s default (5432 for PostgreSQL, 3306 for MySQL and MariaDB, 1433 for SQL Server).
  5. Type the Password. The field says “kept in the system keychain”; once a password is stored it says “stored in the keychain; type to replace”. An empty field keeps the stored password.
  6. Click Test Connection. The result appears in a fixed area above the buttons (see Test a connection).
  7. Click Save, or press ↩. The connection appears in the tree as, for example, “PostgreSQL · db.example.com:5432/shop”, and its schema is read.

Tab and ⇧Tab move between fields, Esc closes the dialog without saving. To change a connection later, select it and press F4 or click ✎ (Data Source Properties…).

The URL field takes a connection URL; ↩ fills the other fields from it. These forms are read:

postgresql://app@db.example.com:5432/shop?sslmode=verify-full
mysql://app@db.example.com:3306/shop?ssl-mode=verify-ca
mariadb://app@db.example.com/shop
sqlserver://app@db.example.com:1433/shop
oracle://app@db.example.com:1521/FREEPDB1
sqlite:data/shop.db
duckdb:data/analytics.duckdb

The schemes of the other built-in systems work as well (cockroachdb://, tidb://, redshift:// and so on) and select that system. A URL that carries a password, in the user part or as password=, is refused: the field is emptied and the message points you to the keychain. JDBC URLs (jdbc:…) are not read here; see Bring connections from IntelliJ IDEA for those.

  1. Choose SQLite (or DuckDB) as the system. The host fields give way to File.
  2. Type the path. A relative path is read from the project folder, so data/shop.db keeps working when the project moves.
  3. If the file does not exist yet, click Create File. It is created with mode 600, never over an existing file and never in a folder that does not exist. Test Connection never creates a file.

The project file .ferris-idea/connections.toml names the keychain entry, never the password:

[ferris-idea]
kind = "connections"
format = 1
[[connection]]
id = "shop"
name = "Shop"
dialect = "postgresql"
host = "db.example.com"
port = 5432
database = "shop"
user = "app"
ssl = "verify-full"
secret = { service = "ferris-idea", account = "connection:shop" }
[[connection]]
id = "local"
name = "Local"
dialect = "sqlite"
path = "data/shop.db"
  • The keychain entry is service ferris-idea, account connection:<id>. Removing a connection (Delete twice in the tree) removes its keychain entry too.
  • The file can be committed: it holds no secret. Keys at their default are left out, and an unknown key makes the whole file an error that names it, rather than being ignored.
  • On Linux without a reachable Secret Service, or with a locked collection, saving is refused with the reason. Ferris IDEA never falls back to a file.
  • When a password is missing, connecting stops before any network access and the message names the connection and the keychain entry.

The SSH/SSL page sets the TLS mode with the SSL button, which steps through the modes:

Mode What it does
verify-full TLS; checks the certificate chain and the host name. The default for a new connection.
verify-ca TLS; checks the chain, not the host name.
require TLS without certificate checks.
prefer Like require. Falls back to an unencrypted connection only for a server on your own machine (localhost, 127.0.0.0/8, ::1, a socket folder), and only after TLS failed. On any other host it acts as require.
disable No TLS.
  • CA file (PEM) replaces the system’s root certificates; it applies with verify-ca and verify-full.
  • Cert file and Key file set a client certificate: PEM with a PKCS#8 key for PostgreSQL, or a password-less .p12/.pfx bundle for PostgreSQL, MySQL and MariaDB. MySQL and MariaDB take bundles only.
  • A key file that others can read is refused (“restrict it with chmod 600”), and so is a key with a passphrase.
  • TLS 1.2 is the minimum. A refused certificate never leads to a weaker mode by itself: the error suggests naming the CA file, or verify-ca when the host name differs.

For PostgreSQL, MySQL and MariaDB (and the systems built on them), the SSH/SSL page has SSH host, SSH port and SSH user.

  1. Type an alias from your ~/.ssh/config or a host name in SSH host, for example build-host.example. Port and user come from your SSH configuration when left empty.
  2. Click Test Connection. The result names the tunnel: “SSH tunnel: build-host.example (local end 127.0.0.1)”.

The tunnel runs your system’s ssh and authenticates with your keys and your SSH agent only. It never asks for a password or a passphrase, refuses a host whose key is not already in your known_hosts, and uses only post-quantum key exchange (OpenSSH 9.0 or later on both ends; ML-KEM from 9.9). ProxyJump entries in your SSH configuration work. TLS still checks the database server’s own host name through the tunnel.

  • Read-only on the General page keeps every console and agent of this connection to reading.
  • Colour steps through red, orange, yellow, green, blue, violet, grey and none, and marks the connection in the Database tree, for example red for production.
  • Comment is shown in the connection’s quick documentation.
  • On the Options page: Auto-commit in consoles and editors (on by default; off starts consoles in manual transactions), Startup script (SQL run after connecting), Connect timeout (10 seconds when empty), Query timeout and Keep-alive in seconds, and Schemas, a filter such as app*, audit (all schemas when empty).
  • The query timeout is applied by PostgreSQL, MySQL and MariaDB; SQLite, SQL Server, Oracle and DuckDB ignore it.

Test Connection uses the fields as they are, runs SELECT 1 (or the system’s own test query) in the background and reports, for example:

Connected to Shop
Server: PostgreSQL 18.6
Driver: tokio-postgres (built in)
Round trip: 2.4 ms
TLS: yes

Copy puts these lines on the clipboard for a bug report; they never contain the password or the user name. When you change a field after a test, the result says “Outdated — the fields changed since the test”.

When the project has the reference IDE’s .idea/dataSources.xml, the Database tool window lists its data sources under “From the project’s .idea, not added yet”, each with Add…. Add fills the dialog with the name, system and file or host, port and database; you enter the user and password. SQLite, PostgreSQL, MySQL, MariaDB and SQL Server sources are read; TLS is set to verify-full whatever the old URL said, and dataSources.local.xml is never read.

Tools › Database › Export Connection… writes a .idcsources file without the keychain reference, the agent permissions, the user name and absolute paths. Someone who imports it adds their own password. Connector definitions of systems you added yourself travel as .idcconnector files next to it; see Database systems.

  • “asks for a password and none was given”: no password is stored for this connection. Edit it (F4) and type the password.
  • “the system keychain cannot be reached in this session”: on Linux, start or unlock your Secret Service (GNOME Keyring, KWallet); over SSH without a desktop session there is often none.
  • A certificate error: name the server’s CA in CA file. If the server’s certificate is issued for another host name, verify-ca checks the chain without the name.
  • A local server without TLS fails with verify-full; the message says that disable is your choice for that server.
  • “needs OpenSSH 9.0 or later; ML-KEM from 9.9”: the SSH server or your client is too old for post-quantum key exchange. Update OpenSSH; there is no fallback.
  • Host key refused: connect once with ssh in a terminal and check the key, so that it is in your known_hosts.
  • SQLite “locked”: another program holds a write lock for longer than SQLite’s 5 second wait.
  • “needs the ODBC route, which Ferris IDEA does not have yet”: systems such as Db2 or Snowflake are in the catalogue but cannot be connected yet.

To report a problem with one database system, use Tools › Database › Report a Problem with This Database…. It builds the report on your machine, replaces host, database and user names with placeholders unless you tick them in, and sends nothing until you copy it or open the issue in your browser.

The Database tool window has no default shortcut; assign one to Database (action ActivateDatabaseToolWindow) in the keymap settings if you open it often. In its tree: ⌘N (CtrlN) new connection, F4 edit, Delete remove. All shortcuts: Keyboard shortcuts.

An agent can list connections and add one without a password (save_connection previews by default and needs the right write); you type the password in the window. Testing or using a connection needs that connection’s permissions, which only you grant: Let an agent use a database.

  • add_idea_data_sourcechangesdry run by defaultwriteAdd a data source from the reference IDE's .idea/dataSources.xml (as idea_project lists it) as a workspace connection, picked by name.
  • database_problem_reportreadsBuild the text of a problem report about a database system for the user to review: Ferris IDEA version, system, status, family, the failing step and error message, with passwords, user names and (unless include_hosts) host, port, database and IP addresses replaced by placeholders.
  • export_connectionreadsA workspace connection as a .idcsources file to share: no keychain reference, no agent permissions, no absolute file path, the user name only with include_user; lists what was left out.
  • list_connectionsreadsList the workspace's database connections (.ferris-idea/connections.toml) with URLs; passwords are never included.
  • remove_connectionchangeswriteRemove a database connection of the workspace and its password in the system keychain, as Delete in the Database tool window does.
  • save_connectionchangesdry run by defaultwriteAdd or change a workspace database connection as the connection dialog does: server or SQLite/DuckDB file, user, SSL (new default verify-full), read-only, SSH tunnel (strict host keys, local end on 127.0.0.1), TLS files and options; omitted fields of a changed connection are kept.
  • test_connectionreadssshdatabase-permissiontrusted-projectTest a workspace database connection: connect with its stored password and run SELECT 1 read-only.