GithubHelp home page GithubHelp logo

Comments (8)

bimalkjha avatar bimalkjha commented on August 25, 2024

@omkarsunku You have not provided any info as requested in the new issue template. Without complete info, it is difficult to help. Please provide complete output of below commands:

 uname
  uname -m
  node -v
  npm ls ibm_db
  db2level
npm install ibm_db

By looking on the error output - odbc_bindings.node: invalid ELF header, it tells that the odbc_bindings.node file is not compatible with the architecture of this system. It seems you have installed ibm_db somewhere else and then copied these file which is incorrect way of using ibm_db. You need to install locally. Now, you can run below commands and share the complete output, not partial:

cd /var/task/node_modules/ibm_db/
npm install

If install is success, then you can try to run your test program. Thanks.

from node-ibm_db.

omkarsunku avatar omkarsunku commented on August 25, 2024

Hello @bimalkjha,

Thanks for the response.

uname
uname -m
node -v
npm ls ibm_db
db2level
Linux
x86_64
v12.22.9
[email protected] /home/ubuntu/lambda-connectDB2
└── [email protected]

db2level: command not found

Ran npm install and below is the complete logs
npm install
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '[email protected]',
npm WARN EBADENGINE required: { node: '>=14.14' },
npm WARN EBADENGINE current: { node: 'v12.22.9', npm: '8.5.1' }
npm WARN EBADENGINE }

[email protected] install
node installer/driverInstall.js

platform = linux, arch = x64, node.js version = v12.22.9
make version =GNU Make 4.3
Rebuild Process: Found clidriver at -> /home/ubuntu/lambda-connectDB2/node_modules/ibm_db/installer/clidriver

Downloading of clidriver skipped - build is in progress...

make: Entering directory '/home/ubuntu/lambda-connectDB2/node_modules/ibm_db/build'
CXX(target) Release/obj.target/odbc_bindings/src/odbc.o
CXX(target) Release/obj.target/odbc_bindings/src/odbc_connection.o
CXX(target) Release/obj.target/odbc_bindings/src/odbc_statement.o
CXX(target) Release/obj.target/odbc_bindings/src/odbc_result.o
SOLINK_MODULE(target) Release/obj.target/odbc_bindings.node
COPY Release/odbc_bindings.node
make: Leaving directory '/home/ubuntu/lambda-connectDB2/node_modules/ibm_db/build'

ibm_db installed successfully.

added 50 packages, and audited 51 packages in 17s

3 packages are looking for funding
run npm fund for details

found 0 vulnerabilities

Then i tried to run my lambda it gave same error
{
"errorType": "Error",
"errorMessage": "/var/task/node_modules/ibm_db/build/Release/odbc_bindings.node: invalid ELF header",
"trace": [
"Error: /var/task/node_modules/ibm_db/build/Release/odbc_bindings.node: invalid ELF header",
" at Module._extensions..node (node:internal/modules/cjs/loader:1340:18)",
" at Module.load (node:internal/modules/cjs/loader:1119:32)",
" at Module._load (node:internal/modules/cjs/loader:960:12)",
" at Module.require (node:internal/modules/cjs/loader:1143:19)",
" at require (node:internal/modules/cjs/helpers:119:18)",
" at bindings (/var/task/node_modules/ibm_db/node_modules/bindings/bindings.js:112:48)",
" at Object. (/var/task/node_modules/ibm_db/lib/odbc.js:57:31)",
" at Module._compile (node:internal/modules/cjs/loader:1256:14)",
" at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)",
" at Module.load (node:internal/modules/cjs/loader:1119:32)"
]
}

from node-ibm_db.

omkarsunku avatar omkarsunku commented on August 25, 2024

Also when i run the below code without a lambda format this works (i have obtained a public DB2 from IBM cloud)
const ibmdb = require('ibm_db');

// Connection details
const connString =
'DATABASE=MY_DB;' +
'HOSTNAME=MY_HOSTNAME' +
'UID=MY_UID;' +
'PWD=MY_PWD;' +
'PORT=32107;' +
"SECURITY=SSL;" +
'PROTOCOL=TCPIP';

// Create a connection
ibmdb.open(connString, (err, conn) => {
if (err) {
console.error('Error connecting to the database:', err);
return;
}

// Database connection is successful, you can now execute SQL queries
conn.query('SELECT * FROM sample_table', (err, rows) => {
    if (err) {
        console.error('Error executing query:', err);
    } else {
        console.log('Query result:', rows);
    }

    // Close the connection
    conn.close((err) => {
        if (err) {
            console.error('Error closing the connection:', err);
        } else {
            console.log('Connection closed.');
        }
    });
});

});

from node-ibm_db.

bimalkjha avatar bimalkjha commented on August 25, 2024

@omkarsunku Your installation of ibm_db is correct. It can be confirmed by running the test file. So, node has no issue in using ibm_db.
As per shared output, the location of installed ibm_db is : /home/ubuntu/lambda-connectDB2/node_modules/ibm_db
So, when you run test program using node, it picks the file /home/ubuntu/lambda-connectDB2/node_modules/ibm_db/build/Release/odbc_bindings.nodeand it is the correct file which get created post install of ibm_db. But, in your error output, we can see the application is trying to load file from/var/task/node_modules/ibm_db/build/Release/odbc_bindings.node`, which is incorrect file and hence error.

You have installed ibm_db in path /home/ubuntu/lambda-connectDB2/node_modules/ibm_db and not at /var/task/node_modules/ibm_db. You need to run below commands:

cd /var/task/node_modules/ibm_db
npm install
node test/test-basic-test.js

Now you'll get correct file /var/task/node_modules/ibm_db/build/Release/odbc_bindings.node. Please share complete output of above npm install command if it still does not work. Thanks.

from node-ibm_db.

bimalkjha avatar bimalkjha commented on August 25, 2024

Basically, below commands are expected to work:

cd /home/ubuntu/lambda-connectDB2/
npm install ibm_db
npm ls ibm_db
vi node_modules/ibm_db/test/config.json => update database  connection info.
node test/test-basic-test.js

cd /var/task/
npm install ibm_db
npm ls ibm_db
vi node_modules/ibm_db/test/config.json => update database  connection info.
node test/test-basic-test.js

Thanks.

from node-ibm_db.

omkarsunku avatar omkarsunku commented on August 25, 2024

Yes this works on Ubuntu at this path cd /home/ubuntu/lambda-connectDB2/ and other path is the lambda path where i can't open the lambda and try that.
Do you have a steps to run a ibm db2 on aws lambda like this looks like a special case where lambda environment is different than which i tried in other path?

from node-ibm_db.

bimalkjha avatar bimalkjha commented on August 25, 2024

@omkarsunku I have no idea about what is lambda. If its an OS, you should be able to login on it and get command prompt and then install. You can getting this issue because lambda OS is definitely different for Ubunto and hence error. Also, it is not amd64 architecture. The ELF error says, you have installed ibm_db on x86_64 architecture and copied it on different architecture, hence error. You must need to install ibm_db locally before use. Installing on one system and copying to another and then use, will not work.
Please go through the issue #912 and #616 in detail, which is about installation of ibm_db on lamda only and users were able to use it successfully. Thanks.

from node-ibm_db.

omkarsunku avatar omkarsunku commented on August 25, 2024

@bimalkjha Thanks for you guidance it worked by adding required files on to the layer. Like i have create a layer with all the below files to zip and attached that layer to lambda.
Files added to create a layer
libaudit.so.1 libcap-ng.so.0 libcrypt.so.1 liblzma.so.5 libpam.so.0 libxml2.so.2

from node-ibm_db.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.