NationalSecurityAgency/ghidra · error · SQLException
Could not create database: {}
Error message
Could not create database: {} What it means
Thrown as an SQLException by H2FileFunctionDatabase.createDatabase() wrapping any SQLException from the parent class's createDatabase, the subsequent initConnection, or the vector table creation. It re-throws with a 'Could not create database' prefix and the original error message, making it clear that the database creation pipeline failed at some internal step.
Source
Thrown at Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/file/H2FileFunctionDatabase.java:120
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 {
try {
super.createDatabase(config);
Connection db = initConnection();
try (Statement st = db.createStatement()) {
vectorTable.create(st);
}
}
catch (final SQLException err) {
throw new SQLException("Could not create database: " + err.getMessage());
}
}
@Override
protected void dropDatabase() throws SQLException {
if (getStatus() == Status.Busy || fileDs.getActiveConnections() != 0) {
throw new SQLException("database in use");
}
close(); // close this instance
if (!fileDs.exists()) {
// ignore request and return
return;
}
// Connect to database and examine schemaView on GitHub (pinned to d5f144c24d)
Solutions
- Read the wrapped message after 'Could not create database: ' to find the specific SQL error (e.g., permission denied, disk full, duplicate key).
- Verify write permissions and available disk space at the target database file path.
- Ensure no other process is using the H2 file during creation.
- Check H2 driver compatibility with the Ghidra version.
- If the error is in vectorTable.create, inspect the DDL and H2 version support for SERIAL/CLOB types.
Example fix
// before
try {
db.createDatabase(config);
} catch (SQLException e) {
// opaque error
}
// after
try {
db.createDatabase(config);
} catch (SQLException e) {
String detail = e.getMessage();
if (detail.contains("Could not create database:")) {
String rootCause = detail.substring(detail.indexOf(':') + 1).trim();
Msg.showError(this, null, "BSim Create Failed",
"Database creation error: " + rootCause);
}
throw e;
} Defensive patterns
Strategy: try-catch
Validate before calling
// Pre-flight checks before database creation
Path dir = dbPath.getParent();
if (!Files.isWritable(dir)) {
throw new IllegalStateException(
"Cannot write to database directory: " + dir);
}
if (dir.toFile().getUsableSpace() < MIN_REQUIRED_SPACE) {
throw new IllegalStateException("Insufficient disk space for database creation");
} Try / catch
try {
database.createDatabase(config);
} catch (SQLException e) {
String msg = e.getMessage();
if (msg.startsWith("Could not create database:")) {
String rootCause = msg.substring(msg.indexOf(':') + 1).trim();
Msg.showError(this, null, "BSim Database Creation Failed",
"Root cause: " + rootCause);
}
throw e;
} Prevention
- Verify write permissions and disk space before calling createDatabase().
- Ensure no other process has the target H2 file open during creation.
- Use a compatible H2 JDBC driver version matched to Ghidra.
- Log the wrapped SQLException message to identify the exact creation step that failed.
When it happens
Trigger: Occurs when super.createDatabase(config) fails (schema setup, metadata insertion), initConnection() fails (file system permission issue, disk full), or vectorTable.create(st) fails (DDL error, H2 driver issue). The underlying SQLException could be from any of these steps during the create flow.
Common situations: Insufficient disk space or file system permissions for the target directory. H2 JDBC driver version incompatibility. Corrupted BSim configuration passed to createDatabase. Concurrent creation attempts on the same file. The parent schema creation encounters a constraint or type error.
Related errors
- Database does not exist: {}
- Database already exists: {}
- database in use
- attempted to drop non-BSim database
- failed to delete H2-file database: {}
AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14).
Data as JSON: /api/errors/1c2276a54020f8e8.
Report an issue: GitHub.