cube-js/cube · error · Error
drivername is required property
Error message
drivername is required property
What it means
JDBCDriver's constructor validates that a resolved JDBC driver class name (drivername) is present before creating the connection pool. It is resolved from config.drivername, the CUBEJS_DB_DRIVER_JDBC env var, or the built-in description of dbType; if all are absent, the constructor throws immediately.
Source
Thrown at packages/cubejs-jdbc-driver/src/JDBCDriver.ts:133
const dbTypeDescription = JDBCDriver.dbTypeDescription(
<string>(config.dbType || getEnv('dbType', { dataSource, preAggregations })),
);
this.config = {
dbType: getEnv('dbType', { dataSource, preAggregations }),
url:
getEnv('jdbcUrl', { dataSource, preAggregations }) ||
dbTypeDescription && dbTypeDescription.jdbcUrl(),
drivername:
getEnv('jdbcDriver', { dataSource, preAggregations }) ||
dbTypeDescription && dbTypeDescription.driverClass,
properties: dbTypeDescription && dbTypeDescription.properties,
...dbOptions
} as JDBCDriverConfiguration;
if (!this.config.drivername) {
throw new Error('drivername is required property');
}
if (!this.config.url) {
throw new Error('url is required property');
}
const poolName = createPoolName('jdbc', dataSource, preAggregations);
this.pool = new Pool(poolName, {
create: async () => {
await initMvn(await this.getCustomClassPath());
if (!this.jdbcProps) {
/** @protected */
this.jdbcProps = this.getJdbcProperties();
}
const getConnection = promisify(DriverManager.getConnection.bind(DriverManager));
return new Connection(await getConnection(this.config.url, this.jdbcProps));View on GitHub (pinned to 7d981676b3)
Solutions
- Pass `drivername` explicitly, e.g. drivername: 'com.mysql.cj.jdbc.Driver'
- Or pass a recognized `dbType` so the built-in mapping supplies the driver class
- Or set the CUBEJS_DB_JDBC_DRIVER environment variable in the deployment
- Double-check the config key is `drivername` (not `driverClass`) and the class name spelling
Example fix
// before
new JDBCDriver({ url: 'jdbc:mysql://host:3306/db' });
// after
new JDBCDriver({ url: 'jdbc:mysql://host:3306/db', drivername: 'com.mysql.cj.jdbc.Driver' }); Defensive patterns
Strategy: validation
Validate before calling
function assertJdbcConfig(cfg) {
if (!cfg.drivername && !cfg.dbType && !process.env.CUBEJS_DB_JDBC_DRIVER) {
throw new Error('JDBCDriver requires `drivername` (or a known `dbType`, or CUBEJS_DB_JDBC_DRIVER env)');
}
return cfg;
}
const driver = new JDBCDriver(assertJdbcConfig(options)); Type guard
function hasJdbcDrivername(cfg) {
return typeof cfg === 'object' && cfg !== null &&
typeof cfg.drivername === 'string' && cfg.drivername.length > 0;
} Try / catch
try {
driver = new JDBCDriver(options);
} catch (e) {
if (e.message === 'drivername is required property') {
throw new Error(`JDBC config for dataSource is missing 'drivername': ${JSON.stringify({ ...options, url: '***' })}`);
}
throw e;
} Prevention
- Always set drivername explicitly in the JDBC driver config
- If relying on dbType, use a documented/known value so the class mapping resolves
- Set CUBEJS_DB_JDBC_DRIVER in deployment env for env-driven setups
- Remember the key is `drivername`, not `driverClass`
When it happens
Trigger: Instantiating new JDBCDriver({...}) without `drivername` and without a `dbType` (or an unknown dbType) whose mapping supplies driverClass, and without CUBEJS_DB_JDBC_DRIVER env set.
Common situations: Using the generic JDBC driver with only a url but no driver class; typo'd dbType not in dbTypeDescription map; env var CUBEJS_DB_JDBC_DRIVER missing in the deployment; passing driverClass instead of drivername in config.
Related errors
- url is required property
- A user-defined contextToApiScopes function returns a wrong s
- Value "${input}" is not valid for ${envName}. ${description}
- Value "${input}" is not valid for ${envName}. Should be a po
- Value "${input}" is not valid for ${envName}. Should be lowe
AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02).
Data as JSON: /api/errors/696ce051eaa78183.
Report an issue: GitHub.