Connecting dremio from nodejs service via jdbc

We have a nodejs proxy service from where we need to fetch data from dremio query engine. We are trying to connect using JDBC. We could not find any direct official documentation for the same.
Question 1 - Is dremio JDBC connection supported from javascript?

Below is our setup -

Dremio version - 24.1.0 container
JDK version - 8
Dremio JDBC driver version - 23.1.0
node version - v20.15.0

With the above setup we are getting the below error -

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to 
the console...
Error connecting to Dremio: [Error: Error running static method
java.sql.SQLException: Failure in connecting to Dremio: cdjd.com.dremio.exec.rpc.RpcException: HANDSHAKE_COMMUNICATION : [USER]: Channel closed null <--> null (user client)
        at com.dremio.jdbc.impl.DremioExceptionMapper.map(DremioExceptionMapper.java:80)
        at com.dremio.jdbc.impl.DremioConnectionImpl.<init>(DremioConnectionImpl.java:104)
        at com.dremio.jdbc.impl.DremioJdbc41Factory.newConnection(DremioJdbc41Factory.java:72)
        at com.dremio.jdbc.impl.DremioFactory.newConnection(DremioFactory.java:67)
        at cdjd.org.apache.calcite.avatica.UnregisteredDriver.connect(UnregisteredDriver.java:138)
        at com.dremio.jdbc.Driver.connect(Driver.java:84)
        at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:682)
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:130)
        at java.base/java.lang.reflect.Method.invoke(Method.java:580)
        at node.MethodCallBaton.invokeMethod9(MethodCallBaton.java:25)
Caused by: cdjd.com.dremio.exec.rpc.RpcException: HANDSHAKE_COMMUNICATION : [USER]: Channel closed null <--> null (user client)
        at cdjd.com.dremio.exec.client.DremioClient$FutureHandler.connectionFailed(DremioClient.java:825)
        at cdjd.com.dremio.sabot.rpc.user.QueryResultHandler$ChannelClosedHandler.connectionFailed(QueryResultHandler.java:387)
        at cdjd.com.dremio.exec.rpc.BasicClient$ConnectionMultiListener$HandshakeSendListener.failed(BasicClient.java:401)
        at cdjd.com.dremio.exec.rpc.RequestIdMap$RpcListener.setException(RequestIdMap.java:193)
        at cdjd.com.dremio.exec.rpc.RequestIdMap$SetExceptionProcedure.apply(RequestIdMap.java:118)
        at cdjd.com.dremio.exec.rpc.RequestIdMap$SetExceptionProcedure.apply(RequestIdMap.java:108)
        at cdjd.com.carrotsearch.hppc.IntObjectHashMap.forEach(IntObjectHashMap.java:692)
        at cdjd.com.dremio.exec.rpc.RequestIdMap.doNotify(RequestIdMap.java:104)
        at cdjd.com.dremio.exec.rpc.RequestIdMap.channelClosed(RequestIdMap.java:71)
        at cdjd.com.dremio.exec.rpc.RemoteConnection.channelClosed(RemoteConnection.java:208)
        at cdjd.com.dremio.exec.rpc.RpcBus$ChannelClosedHandler.operationComplete(RpcBus.java:216)
        at cdjd.com.dremio.exec.rpc.RpcBus$ChannelClosedHandler.operationComplete(RpcBus.java:202)
        at cdjd.io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:578)
        at cdjd.io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:552)
        at cdjd.io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:491)
        at cdjd.io.netty.util.concurrent.DefaultPromise.setValue0(DefaultPromise.java:616)
        at cdjd.io.netty.util.concurrent.DefaultPromise.setSuccess0(DefaultPromise.java:605)
        at cdjd.io.netty.util.concurrent.DefaultPromise.trySuccess(DefaultPromise.java:104)
        at cdjd.io.netty.channel.DefaultChannelPromise.trySuccess(DefaultChannelPromise.java:84)
        at cdjd.io.netty.channel.AbstractChannel$CloseFuture.setClosed(AbstractChannel.java:1182)
        at cdjd.io.netty.channel.AbstractChannel$AbstractUnsafe.doClose0(AbstractChannel.java:773)
        at cdjd.io.netty.channel.AbstractChannel$AbstractUnsafe.close(AbstractChannel.java:749)
        at cdjd.io.netty.channel.AbstractChannel$AbstractUnsafe.close(AbstractChannel.java:620)
        at cdjd.io.netty.channel.DefaultChannelPipeline$HeadContext.close(DefaultChannelPipeline.java:1352)
        at cdjd.io.netty.channel.AbstractChannelHandlerContext.invokeClose(AbstractChannelHandlerContext.java:622)
        at cdjd.io.netty.channel.AbstractChannelHandlerContext.close(AbstractChannelHandlerContext.java:606)
        at cdjd.io.netty.channel.AbstractChannelHandlerContext.close(AbstractChannelHandlerContext.java:472)
        at cdjd.com.dremio.exec.rpc.RpcExceptionHandler.exceptionCaught(RpcExceptionHandler.java:37)
        at cdjd.io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:302)
        at cdjd.io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:281)
        at cdjd.io.netty.channel.AbstractChannelHandlerContext.fireExceptionCaught(AbstractChannelHandlerContext.java:273)
        at cdjd.io.netty.channel.DefaultChannelPipeline$HeadContext.exceptionCaught(DefaultChannelPipeline.java:1377)
        at cdjd.io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:302)
        at cdjd.io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:281)
        at cdjd.io.netty.channel.DefaultChannelPipeline.fireExceptionCaught(DefaultChannelPipeline.java:907)
        at cdjd.io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.handleReadException(AbstractNioByteChannel.java:125)
        at cdjd.io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:177)
        at cdjd.io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:719)
        at cdjd.io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:655)
        at cdjd.io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:581)
        at cdjd.io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493)
        at cdjd.io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986)
        at cdjd.io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
        at java.base/java.lang.Thread.run(Thread.java:1575)
Caused by: cdjd.com.dremio.exec.rpc.ChannelClosedException: [USER]: Channel closed null <--> null (user client)
        at cdjd.com.dremio.exec.rpc.RpcBus$ChannelClosedHandler.operationComplete(RpcBus.java:214)
        ... 33 more
] {
  cause: nodeJava_java_sql_SQLException {}

this is our nodejs code for connection

const java = require('java');

// Set up the classpath for the JDBC driver
java.classpath.push('dremio-jdbc-driver-23.1.0-202211250136090978-a79618c7.jar');

// Set up the connection to Dremio
const url = 'jdbc:dremio:direct=localhost:31010';
const user = 'xx';
const password = 'xx';

// Load the JDBC classes
const DriverManager = java.import('java.sql.DriverManager');
const Properties = java.import('java.util.Properties');

// Configure properties
const properties = new Properties();
properties.putSync('user', user);
properties.putSync('password', password);

// Connect to the Dremio server
DriverManager.getConnection(url, properties, (err, conn) => {
    if (err) {
        return console.error('Error connecting to Dremio:', err);
    }

    console.log('Connected to Dremio successfully!');

    // Execute a query
    const stmt = conn.createStatementSync();
    const rs = stmt.executeQuerySync(' SELECT * FROM Samples."samples.dremio.com"."NYC-taxi-trips"."1_5_1.parquet" limit 5');  // Adjust query

    while (rs.nextSync()) {
        console.log(rs.getStringSync(1)); // Example: print first column
    }

    // Close the connection
    conn.closeSync();
});

Please guide with the above issue.

Also if you could suggest if there are any alternative approaches. We are not keen on API connection.

@akshaymehtadremio Looks like this is currently not supported

Hi @balaji.ramaswamy, thanks for the response. Can you please clarify a little. Do you mean connecting from nodejs itself is not supported? Or JDBC from nodejs is not supported and there is any alternate?

if you use graalvm nodejs using jdbc maybe very easy