ibmdb / node-ibm_db

IBM DB2 and IBM Informix bindings for node
MIT License
192 stars 150 forks source link

SQL1013N The database alias name or database name "" could not be found. #813

Closed jyotheeshInfy closed 2 years ago

jyotheeshInfy commented 2 years ago

I have been tring to connect to DB2 and it says database name is not found, i have given the correct db name and also tried it in upper case also, i have contacting the ibm support as well about this and it was all fine at there side. It is not showing the database name in error message although i have given it in the code.

below is the code I am using

var ibmdb = require("ibm_db"); var connStr = "DATABASE=BLUDB;HOSTNAME=<>.cloud.ibm.com;UID=<>;PWD=<>;PORT=<>;PROTOCOL=SSL";

ibmdb.open(connStr, function (err,conn) { console.log(connStr); if (err) return console.log(err); console.log("conn:"); console.log(conn); conn.query('SELECT * FROM <>.<>;', function (err, data) { if (err) console.log(err); else console.log(data);

  conn.close(function () {
    console.log('done closed');
  });
});

});

below is the error message i getting:

{ [Error: [IBM][CLI Driver] SQL1013N The database alias name or database name "" could not be found. SQLSTATE=42705 ] error: '[node-ibm_db] SQL_ERROR', sqlcode: -1013, message: '[IBM][CLI Driver] SQL1013N The database alias name or database name "" could not be found. SQLSTATE=42705\r\n', state: '08001' }

could you please let me know what is going wrong here?

bimalkjha commented 2 years ago

@jyotheeshInfy Are you using any db2cli.ini or db2dsdriver.cfg file? Please share the complete output of below commands:

node -v
db2level
db2cli validate -database "<dbname>:<hostname>:<tcpip_port>" -user <dbuser> -passwd <dbpasswd> -connect

Update ibm_db\installer\testODBCConnection.sh and uncomment line no 32 to run your test program using this script. Save the script and run it to capture traces. Zip all generated 1.* files and attach here. Thanks.

jyotheeshInfy commented 2 years ago

i am not using db2cli.ini or db2dsdriver.cfg file.

F:>node -v v10.18.1

F:>db2level DB21085I This instance or install (instance name, where applicable: "*") uses "64" bits and DB2 code release "SQL11055" with level identifier "0606010F". Informational tokens are "DB2 v11.5.5000.1587", "s2011011400", "DYN2011011400WIN64", and Fix Pack "0". Product is installed at "C:\Cloud\clidriver" with DB2 Copy Name "IBM Data Server Driver For ODBC and CLI"

1.zip

it gives this error in the .zip file: [FAILED]: [IBM][CLI Driver] SQL30081N A communication error has been detected. Communication protocol being used: "TCP/IP". Communication API being used: "SOCKETS". Location where the error was detected: "". Communication function detecting the error: "connect". Protocol specific error code(s): "10060", "", "". SQLSTATE=08001

but in my code i have used protocol as SSL in the connStr

jyotheeshInfy commented 2 years ago

@bimalkjha any solutions for this issue?

bimalkjha commented 2 years ago

@jyotheeshInfy So, you have two clidriver: 1. C:\ccm\db2-conect-test\node_modules\ibm_db\installer\clidriver and 2. C:\Cloud\clidriver. So causing confusion. If you have used protocol as SSL in connStr, make sure you use PORT= and not the TCPIP port. Both are different. TCPIP port is used without Protocol=SSL in connection string. Try to get rid of two clidrivers. If you want to use "C:\Cloud\clidriver" only, then set system environment variable IBM_DB_HOME=C:\Cloud\clidriver and then reinstall ibm_db. Retry running testODBCConnection.sh with both TCPIP port without protocol=SSL and with SSL port with protocol=SSL. Check the you have the clidriver\cfg\DigiCertGlobalRootCA.arm file which is used to connect to DashDB in cloud. Initially you was getting SQL1013N error but using testODBCConnection.sh you are getting SQL30081N error. Check why? If PATH and library path system environment variable is incorrect, correct it. Thanks.

jyotheeshInfy commented 2 years ago

@bimalkjha I have tried by setting the environment variable IBM_DB_HOME one of the 2 cli's i have.

say per the protocol i have tried with TCPIP but i am getting the following error msg, so i have checked in db2 console and says "with SSL: yes", thats why i am using SSL [Error: [IBM][CLI Driver] SQL30081N A communication error has been detected. Communication protocol being used: "TCP/IP". Communication API being used: "SOCKETS". Location where the error was detected: "". Communication function detecting the error: "selectForConnectTimeout".
Protocol specific error code(s): "0", "", "". SQLSTATE=08001 ] { error: '[node-ibm_db] SQL_ERROR', sqlcode: -30081, state: '08001' } in the testODBCConnection.sh file i didnt know the syntax to include protocol in the command. I tried the bellow command and it gave me a syntax error. db2cli validate -database "sample:hotel.torolab.ibm.com:21169" -protocol SSL -connect -user newton -passwd serverpass

using testODBCConnection.sh i am getting SQL30081N error is because of the above reason, i have rain the command without specifying the protocol and by default it took TCPIP as the protocol.

and in the error message of this issue it is showing the database name as an empty string, does this mean that it is not taking the database name or it is not showing it in the error message?

bimalkjha commented 2 years ago

@jyotheeshInfy You are using wrong db2cli validate command. You need to comment or remove the db2cli validate command in ibm_db\installer\testODBCConnection.sh and uncomment the line no 32 and use the node test.js command that is giving error. You can run your node.js test program using ibm_db\installer\testODBCConnection.sh to verify the connection. db2cli validate is not possible using SSL port, so error is expected.

jyotheeshInfy commented 2 years ago

okay, even if i do the db2cli command correctly also i am still going to the same error. I have checked about this with the IBM support team also but they say that its fine at there end and to check if there is any problem with ibm_db. What could be causing this problem? and do we have any solution for this?

bimalkjha commented 2 years ago

@jyotheeshInfy I am not suggesting you to use db2cli validate command. It can not be used for SSL connection. It is used only for TCPIP connection. Do you have any node.js test program to reproduce the SQL1013N error? If yes, save it as test.js. Then open file testODBCConnection.sh, add a # before line no 29 at start and remove the # from line no 32. Modify line no 32 as node test.js and save the file. Then run the testODBCConnection.sh script. It should not run db2cli validate command but it should run node test.js command. Thanks.

bimalkjha commented 2 years ago

Remove the line db2cli validate from testODBCConnection.sh and put node test.js.

bimalkjha commented 2 years ago

@jyotheeshInfy Any update? Thanks.

jyotheeshInfy commented 2 years ago

The problem got resolved.

I was trying to do this from a private intranet. So, the firewall blocked the request to to go out of the intranet. Ones I deployed the code and it worked fine. You can close the issue.

Thank you, Sorry for the delayed update.