rodhoward / node-sybase

23 stars 55 forks source link

Error: spawn java ENOENT (windows) #40

Closed Leccho closed 2 years ago

Leccho commented 2 years ago

I'm getting this error when trying to connect to my database:

Error: spawn java ENOENT

Here's my code:

const Sybase: any = require('sybase');
const db: any = new Sybase('host', port, 'database', 'user', 'password');
db.connect(); // crashing here

Here's the librairy's code where the error is happening:

Sybase.prototype.connect = function(callback)
{
    var that = this;
    console.log(this.pathToJavaBridge); // C:\...\node_modules\sybase\JavaSybaseLink\dist\JavaSybaseLink.jar
    this.javaDB = spawn('java',["-jar",this.pathToJavaBridge, this.host, this.port, this.dbname, this.username, this.password]);
    ...
}

Doing the following command in C:\...\node_modules\sybase\JavaSybaseLink\dist\ will print connected to the console:

java -jar JavaSybaseLink.jar host port user password

So I'm confused as why it's not working...

Leccho commented 2 years ago

Looks like since vscode was not running as administrator, he could not access the java command.