oracle / node-oracledb

Oracle Database driver for Node.js maintained by Oracle Corp.
http://oracle.github.io/node-oracledb/
Other
2.24k stars 1.07k forks source link

Connecting to Oracle XE 21c running in Docker container #1537

Closed jmc420 closed 1 year ago

jmc420 commented 1 year ago

I am running Oracle XE 21c in a Docker container and I can connect to it with a JDBC thin connection using the JDBC url jdbc:oracle:thin:@localhost:1521:XE using the SYSTEM account. I can also connect with sqlplus either by logging into the terminal Docker instance or by using sqlplus on the host OSX machine.

When I try to connect to it using NodeJS OracleDB example code described here:

https://node-oracledb.readthedocs.io/en/latest/user_guide/connection_handling.html, I cannot get the client to connect using either:

connection = await oracledb.getConnection({
      user          : "hr",
      password      : mypw
      connectString : "localhost/XEPDB1"
    });

or

 connection = await oracledb.getConnection({
    user          : "SYSTEM",
    password      : "MyPassword",
    connectString : "localhost/XE"
   });

I get an error ORA-01017: invalid username/password; logon denied.

sqlplus works fine if I use this connection string sqlplus SYSTEM/Password@localhost:1521/XE

if I change the code to:

     const connection = await oracledb.getConnection({
                    //user: connectionURI.user,
                    //password: connectionURI.password,
                    connectString: "SYSTEM/Password@localhost:1521/XE"
                });

I get the error ORA-12154: TNS:could not resolve the connect identifier specified

It seems odd that I can connect with sqlplus but not with node-oracledb. Any ideas?

cjbj commented 1 year ago

Do you have a case sensitive password?

I would expect this syntax to work:

 connection = await oracledb.getConnection({
    user          : "SYSTEM",
    password      : "MyPassword",
    connectString : "localhost/XE"
   });

or with connectString : "localhost/XEPDB1"

This is not valid syntax for node-oracledb: connectString: "SYSTEM/Password@localhost:1521/XE"

There is no default password for the HR user. You can create the HR user using the scripts in https://github.com/oracle-samples/db-sample-schemas

jmc420 commented 1 year ago

Thanks, It's now all working.