node-jdbc icon indicating copy to clipboard operation
node-jdbc copied to clipboard

Could not find class com.kognitio.jdbc.Driver

Open suman90 opened this issue 7 years ago • 1 comments

I'm trying to use this module to setup connectivity to a standalone kognitio db using the latest driver jar. I have written below test file and I'm facing the java.lang.ClassNotFoundException in the initialize() function. Please help.

const JDBC = require('jdbc');
const jinst = require('jdbc/lib/jinst');

class KognitioConnection {
	constructor() {
		if (!jinst.isJvmCreated()) {
			jinst.addOption('-Xrs');
			jinst.setupClasspath(['./KognitioJDBC.jar']);
		}
		this.config = {
			url: 'jdbc:kognitio://<database server url>',
			drivername: 'com.kognitio.jdbc.Driver',
			user: '<username>',
			password: '<password>'
		};
		this.wx2db = new JDBC(this.config);
		this.wx2db.initialize((err) => {
			if (err) {
				throw Error(err);
			}
		});
	}
}
module.exports = new KognitioConnection();

Error Log (with folder paths changed):

Error: Error: Could not find class com.kognitio.jdbc.Driver
java.lang.NoClassDefFoundError: com/kognitio/jdbc/Driver
Caused by: java.lang.ClassNotFoundException: com.kognitio.jdbc.Driver
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

    at KognitioConnection.wx2db.initialize (D:\<folders>\Kognitio\kognitioConnection.js:25:11)
    at D:\<folders>\node_modules\jdbc\lib\pool.js:137:16
    at JDBC.Pool.initialize (D:\<folders>\node_modules\jdbc\lib\pool.js:135:10)
    at new KognitioConnection (D:\<folders>\Kognitio\kognitioConnection.js:23:14)
    at Object.<anonymous> (D:\<folders>\Kognitio\kognitioConnection.js:62:18)
    at Module._compile (internal/modules/cjs/loader.js:678:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:689:10)
    at Module.load (internal/modules/cjs/loader.js:589:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:528:12)
    at Function.Module._load (internal/modules/cjs/loader.js:520:3)

Process finished with exit code 1

suman90 avatar May 09 '18 21:05 suman90

I assume KognitioJDBC.jar is in the top level of your project? If it is, I'm not sure why it's not finding the class. You may also want to try a full path to the driver.

CraZySacX avatar Jun 14 '18 02:06 CraZySacX