1

I created an action into IbM Cloud Fucntions to insert data into DB2.

I declare the variable DSN with the credentials given by IBM.

var dsn = "DATABASE=BLUDB;HOSTNAME=dashdb-entry-yp-dal09-08.services.dal.bluemix.net;PORT=50000;PROTOCOL=TCPIP;UID=dash100113;PWD=*******"

I got this error:

message : "[IBM][CLI Driver] CLI0199E Invalid connection string attribute. SQLSTATE=08001"

This is the code I use to insert the data:

function insertClient(dsn) {
 try {
    var conn=ibmdb.openSync(dsn);
    var data=conn.querySync("insert into client (name) values ('jamie')");
    conn.closeSync();
    return {result : data};
 } catch (e) {
     return { dberror : e }
 }
}

I expect to connect and insert the data.

Can anyone help?

1
  • 1
    Try to place the ; character at the end of your connection string. Commented May 23, 2019 at 5:30

1 Answer 1

1

First of all, you should not hardcode the credentials for security reasons. You can bind the service to your actions using IBM Cloud Functions commands. You can find code samples provided in this tutorial that uses functions with various Db2 operations. By avoiding hardcoded credentials you also do not run into copy & paste errors.

Second, all connection attributes end with a ";". Add one after the password attribute.

Third, try to use SSL connections instead of regular connections.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Henrik. All works fine with the help of the tutorial.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.