Comments (7)
Opened a PR @ idb-connector repo concerning above issue.
Version 1.0.0 of idb-pconnector released supporting username & passwords for connection.
Marking this issue as resolved!
from nodejs-idb-pconnector.
@dmabupt while creating a test case for the Updated idbp-connector
method connect(url, usernmae, password) , I noticed that errors were not being thrown by the idc-connectors's dbconn.conn()
.
For Example:
let conn = new Connection();
conn.debug(true);
dbConn.connect('*LOCAL', 'fake', 'fake');
I would expect an error to be thrown by the underlying dbconn's .conn() but an error is not thrown.
Looking at the output from points out that it dd fail but the error was just not thrown.
SQLConnect(-1): conn obj [18031b410] handler [2]
**** ERROR *****
SQLSTATE: 08001
Native Error Code: -30082
Authorization failure on distributed database connection attempt.
``
Looking @ the underlying idb-connector code I think I know why the error was not thrown.
Before converting the idb-connector to be napi compliant the [void throwErrMsg(int handleType, Isolate* isolate)](https://bitbucket.org/litmis/nodejs-idb-connector/src/6ca9ff8060a012177f002d5833d8ad7f0ed3e58c/src/db2ia/dbconn.h?at=1.0.13&fileviewer=file-view-default#dbconn.h-119) would throw an error at the end.
The but somehow the Napi version of [void throwErrMsg(int handleType, Isolate* isolate)](https://bitbucket.org/litmis/nodejs-idb-connector/src/16bf93548e688b92594d7951b886d661e0ecf0aa/src/db2ia/dbconn.h?at=master&fileviewer=file-view-default#dbconn.h-89) does not throw the java script error at the end.
I suspect adding `Napi::Error::New(env, Napi::String::New(env, errMsg)).ThrowAsJavaScriptException();` to line 90 of dbconn.h would fix this :smiley: .
from nodejs-idb-pconnector.
Yes, we can skip the isLocal check because connecting without a username & password should only work when using '*LOCAL' anyway.
When using '*LOCAL' and you don't provide username & password, your current user profile info would be used for you.
#!js
...
/**
* Instantiates a new Connection instance
*/
newConnection() {
let me = this,
{url, username = '', password = ''} = me.database;
me.conn = new idbp.Connection();
if (!username && !password) {
me.conn.connect(url);
} else {
me.conn.connect(url, username, password);
}
}
from nodejs-idb-pconnector.
Original comment by Brian Jerome (Bitbucket: bjerome, GitHub: brianmjerome).
In that case I think we can skip checking for isLocal
completely, correct?
from nodejs-idb-pconnector.
@brianmjerome Thanks! I like the implementation using destructing assignment.
Instead of always skipping connecting with username & password if the url is "*LOCAL" I would tweak it to:
#!js
...
/**
* Instantiates a new Connection instance
*/
newConnection() {
let me = this,
{url, username = '', password = ''} = me.database,
isLocal = url === '*LOCAL';
me.conn = new idbp.Connection();
if (isLocal && !username && !password) {
me.conn.connect(url);
} else {
me.conn.connect(url, username, password);
}
}
That way if a username and password is provided & the url is local then an attempt to connect with the username & password is made.
Currently trying to have the idb-pconnector be used as transport option within itoolkit. Looking at the examples, username and passwords are passed along to connect even when using "*LOCAL".
from nodejs-idb-pconnector.
Original comment by Brian Jerome (Bitbucket: bjerome, GitHub: brianmjerome).
@abmusse
This is what I had originally for Connection supporting user/pwd. Feel free to reference if needed :)
#!javascript
...
/**
* Constructor to instantiate a new instance of a Connection class given the `poolIndex` and `config`
* @param poolIndex An identifier for debug purposes
* @param config Object includes `database`
*/
constructor(poolIndex, config = {database: {url: '*LOCAL'}}) {
let me = this,
{database} = config;
// Defaults are initialized if `config` does not have all properties defined at instantiation.
me.database = database || {url: '*LOCAL'};
...
me.newConnection();
...
}
/**
* Instantiates a new Connection instance
*/
newConnection() {
let me = this,
{url, username = '', password = ''} = me.database,
isLocal = url === '*LOCAL';
me.conn = new idbp.Connection();
if (isLocal) {
me.conn.connect(url);
} else {
// Username and Password are assumed blank if not specified with non-local URL.
me.conn.connect(url, username, password);
}
}
from nodejs-idb-pconnector.
Thanks For the Suggestion!
I'm Currently working on an Implementation.
from nodejs-idb-pconnector.
Related Issues (20)
- setLibraryList and sql user defined functions HOT 5
- dbpool failed to detach HOT 19
- Run linter during PR HOT 1
- Fix eslint errors
- Max number of simultaneous connections HOT 8
- Drop standard-version as its now deprecated HOT 2
- Calling Store Proc passing well IN parms , not getting OUT parm HOT 2
- DBPool example is incomplete.. HOT 1
- Please make more clear how to call a Stored Procedure HOT 7
- No clear explanation on how to call stored procedure. Not receiving output.
- More examples HOT 5
- bindParam() is deprecated and you should use bindParameters() instead HOT 8
- Fix copyright headers on source files
- Add package-lock.json HOT 1
- DBPool 'new connection' event emitter issues HOT 1
- build: Add standard-version HOT 1
- Migrate docs to readthedocs HOT 1
- Add exempt-pr-label
- DBPool.prepareExecute should provide a way to enable numeric type conversion HOT 7
- fetchAll keys lower case HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nodejs-idb-pconnector.