Reputation: 23
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?
Upvotes: 1
Views: 502
Reputation: 17118
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.
Upvotes: 1