Skip to content

Commit

Permalink
instant client almost working
Browse files Browse the repository at this point in the history
  • Loading branch information
rathboma committed Feb 28, 2024
1 parent d088fab commit a694c31
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 8 deletions.
1 change: 0 additions & 1 deletion apps/studio/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"scripts": {
"serve": "vue-cli-service serve",
"test:unit": "TEST_MODE=1 ELECTRON_RUN_AS_NODE=1 yarn electron ../../node_modules/jest/bin/jest.js",
"test:integration": "TEST_MODE=1 ELECTRON_RUN_AS_NODE=1 yarn electron ../../node_modules/jest/bin/jest.js --config ./jest.integration.config.js",
"lint": "vue-cli-service lint",
"electron:build": "vue-cli-service electron:build",
"electron:serve": "vue-cli-service electron:serve --host localhost --ozone-platform-hint=auto",
Expand Down
11 changes: 7 additions & 4 deletions apps/studio/src/lib/db/clients/oracle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -491,15 +491,18 @@ export class OracleClient extends BasicDatabaseClient<DriverResult> {
async connect() {

const cliLocation = this.platformPath(this.server.config.instantClientLocation)

// https://oracle.github.io/node-oracledb/doc/api.html#-152-optional-oracle-net-configuration
const configLocation = this.platformPath(this.server.config.oracleConfigLocation)

console.log("Connecting to oracle")
console.log("CLI LOCATION", cliLocation)

try {
const payload = {}
if (cliLocation) payload['libDir'] = cliLocation
if (configLocation) payload['configDir'] = configLocation
oracle.initOracleClient(payload)
// oracle.initOracleClient(payload)
oracle.initOracleClient()
oracle.fetchAsString = [oracle.CLOB]
oracle.fetchAsBuffer = [oracle.BLOB]
} catch {
Expand Down Expand Up @@ -529,9 +532,9 @@ export class OracleClient extends BasicDatabaseClient<DriverResult> {
poolMax: 4,
}
}

console.log("MAKING POOL")
this.pool = await oracle.createPool(poolConfig)

console.log("POOL MADE")
const vSQL = `
SELECT BANNER as BANNER FROM v$version
WHERE BANNER LIKE 'Oracle%';
Expand Down
4 changes: 4 additions & 0 deletions apps/studio/tests/integration/lib/db/clients/oracle.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ describe("Oracle Tests", () => {

beforeAll(async () => {
// this is the testcontainers default startup wait time.
console.log("ENV/ORACLE CLI: ", process.env['ORACLE_CLI_PATH'])
console.log("ENV/LD_LIBRARY_PATH: ", process.env['LD_LIBRARY_PATH'])
const timeoutDefault = 120000
jest.setTimeout(timeoutDefault)
const localDir = path.resolve('./tests/docker/oracle_init')
Expand All @@ -39,13 +41,15 @@ describe("Oracle Tests", () => {
client: 'oracle',
host: container.getHost(),
port: container.getMappedPort(1521),
instantClientLocation: process.env['ORACLE_CLI_PATH'],
user: 'beekeeper',
password: 'password',
serviceName: 'BEEKEEPER',
options: {
connectionMethod: 'manual'
}
}
console.log("connecting with config", config)
util = new DBTestUtil(config, "BEEKEEPER", { defaultSchema: 'BEEKEEPER', dialect: 'oracle' })
await util.setupdb()

Expand Down
3 changes: 2 additions & 1 deletion bin/get-instant-client.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ then
else
wget -q -O cli.zip \
https://download.oracle.com/otn_software/linux/instantclient/216000/instantclient-basic-linux.x64-21.6.0.0.0dbru.zip

# wget -q -O cli.zip \
# https://download.oracle.com/otn_software/linux/instantclient/23c/instantclient-basic-linux.x64-23.3.0.0.0.zip
rm -rf $LOCATION/*
unzip cli.zip -d $LOCATION
fi
Expand Down
3 changes: 2 additions & 1 deletion bin/integration-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ LOCATION="$BASE/.instant"

eval "$BINBASE/get-instant-client.sh '$LOCATION'"

export LD_LIBRARY_PATH="$LOCATION/instantclient_21_6"
export ORACLE_CLI_PATH="$LOCATION/instantclient_21_6/"
export LD_LIBRARY_PATH="$ORACLE_CLI_PATH"
export ELECTRON_RUN_AS_NODE=1
export TEST_MODE=1

Expand Down
11 changes: 10 additions & 1 deletion docs/user_guide/connecting/oracle-database.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,16 @@ There are a number of ways you can connect to an Oracle database using Beekeeper
2. TSA alias
3. Host and port

## First set Oracle Instant Client location
## Prerequisites

### Linux: Install libaio

```bash
sudo apt-get install libaio1 libaio-dev #debian/ubuntu
sudo yum install libaio #redhat/fedora
```

### Download Oracle Instant Client

Before you can connect to Oracle at all you need to tell Beekeeper where on your computer the Oracle Instant Client libraries are stored. This is a downloadable set of files provided by Oracle.

Expand Down

0 comments on commit a694c31

Please sign in to comment.