NationalSecurityAgency/ghidra · error · SQLException

Database does not exist: {}

Error message

Database does not exist: {}

What it means

Thrown as an SQLException by H2FileFunctionDatabase.initConnection() when the database status is not Ready and the underlying H2 file data source does not exist on disk. This is a guard that prevents attempting to open an H2 connection to a database file that was never created or has been deleted.

Source

Thrown at Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/file/H2FileFunctionDatabase.java:92

		vectorTable = new H2VectorTable(vectorFactory, vectorStore);
	}

	@Override
	public void close() {
		vectorTable.close();
		super.close();
	}

	@Override
	protected void setConnectionOnTables(Connection db) {
		vectorTable.setConnection(db);
		super.setConnectionOnTables(db);
	}

	@Override
	protected Connection initConnection() throws SQLException {
		if (getStatus() != Status.Ready && !fileDs.exists()) {
			throw new SQLException(
				"Database does not exist: " + fileDs.getServerInfo().getDBName());
		}
		return super.initConnection();
	}

	@Override
	protected void generateRawDatabase() throws SQLException {
		BSimServerInfo serverInfo = fileDs.getServerInfo();
		if (fileDs.exists()) {
			throw new SQLException("Database already exists: " + serverInfo.getDBName());
		}
		try (Connection c = fileDs.getConnection()) {
			// do nothing - should throw exception on error
		}
	}

	@Override
	protected void createDatabase(Configuration config) throws SQLException {

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Verify the H2 database file path in the BSim URL is correct and the file exists on disk.
  2. If the database should exist, run the BSim database creation command to generate it first.
  3. Check file system permissions on the directory containing the database.
  4. Use fileDs.exists() or BSimServerInfo path validation before attempting to connect.

Example fix

// before
H2FileFunctionDatabase db = new H2FileFunctionDatabase(serverInfo);
db.initialize(); // throws if file missing

// after
Path dbPath = Paths.get(serverInfo.getDBName());
if (!Files.exists(dbPath)) {
    throw new IOException("BSim H2 database not found: " + dbPath);
}
H2FileFunctionDatabase db = new H2FileFunctionDatabase(serverInfo);
db.initialize();
Defensive patterns

Strategy: validation

Validate before calling

// Verify H2 database file exists before connecting
Path dbPath = Paths.get(serverInfo.getDBName());
if (!Files.exists(dbPath)) {
    throw new FileNotFoundException(
        "BSim H2 database file does not exist: " + dbPath);
}

Try / catch

try {
    database.initialize();
} catch (SQLException e) {
    if (e.getMessage().startsWith("Database does not exist:")) {
        // Either create the database or correct the path
        if (shouldCreate) {
            database.createDatabase(config);
        } else {
            showErrorDialog("BSim Database Not Found", e.getMessage());
        }
    }
    throw e;
}

Prevention

When it happens

Trigger: Occurs when initConnection() is called on an H2FileFunctionDatabase whose fileDs.exists() returns false and the database hasn't already reached Status.Ready. This happens when: the URL points to a file path that doesn't exist, the database was never created (generateRawDatabase/createDatabase was never called), or the file was deleted externally.

Common situations: Specifying an H2 BSim URL to a database that hasn't been generated yet. Typo in the file path. The database file was manually deleted from disk. Trying to query a database that was dropped by another Ghidra instance.

Related errors


AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14). Data as JSON: /api/errors/3ceb78bede9b43a8. Report an issue: GitHub.