cubejs-jdbc-driver-for-msfabric
v1.3.10
Published
Cube.js MS Fabric database driver
Readme
Website • Docs • Blog • Slack • Twitter
Cube.js JDBC Database Driver custom for MS Fabric
JDBC driver for MS Fabric
Support
This package is community supported and should be used at your own risk.
Java installation
macOS
brew install openjdk
# At the moment of writing, openjdk 22.0.1 is the latest and proven to work on Intel/M1 Mac's
# Follow the brew suggested advice at the end of installation:
# For the system Java wrappers to find this JDK, symlink it with
sudo ln -sfn /usr/local/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk
# Ensure that newly installed jdk is visible
/usr/libexec/java_home -V
# You should see installed jdk among others, something like this:
Matching Java Virtual Machines (3):
22.0.1 (x86_64) "Homebrew" - "OpenJDK 22.0.1" /usr/local/Cellar/openjdk/22.0.1/libexec/openjdk.jdk/Contents/Home
1.8.0_40 (x86_64) "Oracle Corporation" - "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home
# Set JAVA_HOME environment variable before running yarn in the Cube repo
export JAVA_HOME=`/usr/libexec/java_home -v 22.0.1`Note: It's important to set JAVA_HOME prior to running yarn/npm install in Cube repo as Java Bridge npm package
uses is to locate JAVA and caches it internally. In case you already run package installation you have to rebuild
all native packages or just delete node_modules and run yarn again.
Debian, Ubuntu, etc.
sudo apt install openjdk-24-jdkWindows
If you have Chocolatey packet manager:
choco install openjdkHow to use
Install packages
npm install cubejs-jdbc-driver-for-msfabric @cubejs-backend/server @cubejs-backend/mssql-driverSetup a cube.js file
// Cube.js configuration options: https://cube.dev/docs/config
const { MSFabricDriver } = require("cubejs-jdbc-driver-for-msfabric");
const path = require('path');
module.exports = {
dialectFactory: MSFabricDriver.dialectClass,
driverFactory: ({ securityContext }) => {
const baseConfig = {
drivername: 'com.microsoft.sqlserver.jdbc.SQLServerDriver',
customClassPath: [
// Core SQL Server JDBC driver - Required for basic database connectivity
path.resolve('drivers/mssql-jdbc-12.10.1.jre11.jar'),
// MSAL4J - Microsoft Authentication Library for Java
// Handles Azure AD authentication and token acquisition
path.resolve('drivers/msal4j-1.13.10.jar'),
// Azure Identity SDK - get token AAD
path.resolve('drivers/azure-identity-1.15.4.jar'),
// Required for MSAL4J token handling
path.resolve('drivers/oauth2-oidc-sdk-11.26.jar'),
path.resolve('drivers/nimbus-jose-jwt-10.3.1.jar'),
path.resolve('drivers/content-type-2.3.jar'),
path.resolve('drivers/slf4j-api-2.0.17.jar'),
path.resolve('drivers/slf4j-simple-1.7.36.jar'),
path.resolve('drivers/json-smart-2.5.2.jar'),
path.resolve('drivers/accessors-smart-2.5.2.jar'),
path.resolve('drivers/jackson-core-2.13.3.jar'),
path.resolve('drivers/jackson-annotations-2.12.7.jar'),
path.resolve('drivers/jackson-databind-2.12.7.2.jar'),
],
properties: {
user: process.env.DB_USER,
password: process.env.DB_PASS,
},
maxRows: 50000,
queryTimeout: 600,
poolOptions: {
min: 0,
max: 8,
idleTimeoutMillis: 30000
}
};
const host = process.env.DB_HOST_US;
const database = process.env.DB_NAME_US;
const jdbcUrl =[
`jdbc:sqlserver://${host}`,
`;database=${database}`,
`;encrypt=true`,
`;trustServerCertificate=false`
];
if (securityContext.entity_name === 'local') {
jdbcUrl.push(`;UserName=${process.env.DB_USER_LOCAL}`);
jdbcUrl.push(`;Password=${process.env.DB_USER_LOCAL}`);
} else {
jdbcUrl.push(`;authentication=${process.env.DB_AUTHENTICATION}`);
jdbcUrl.push(`;UserName=${process.env.CUBEJS_FABRIC_CLIENT_ID}`);
jdbcUrl.push(`;Password=${process.env.CUBEJS_FABRIC_CLIENT_SECRET}`);
}
return new MSFabricDriver({
...baseConfig,
database,
url: jdbcUrl.join(''),
});
},
};
License
Cube.js JDBC Database Driver is Apache 2.0 licensed.
