paulomcnally/jt400.js

Close connection

Opened this issue · 1 comments

When i try to close connection I have an error

"TypeError: Cannot read property 'close' of null"

var Database = require('jt400');
var database = new Database();

var config = {
  libpath: __dirname + '/jt400.jar',
  drivername: 'com.ibm.as400.access.AS400JDBCDriver',
  url: 'jdbc:as400://127.0.0.1/myDatabase;user=myUser;password=myPassword'
};

database.initialize(config);
database.open();
database.execute("select * from mtfusrp "); 
database.on('execute', function(error, results) {
    if (error) {
       console.log(error);
   }
   else {
     console.log(result);
  }
});
database.close();

What is the right way to open and close a connection !

Try call close method after callback is finished