DBA Hub

📋Steps in this guide1/6

SQLcl : Installation

This short post describes the simple process to install SQLcl.

oracle miscconfigurationintermediate
by OracleDba
16 views
1

Downloads

If you are doing the RPM installation, ignore this section. SQLcl requires a Java installation. That's probably going to be present on most servers anyway, but we'll assume it's not in this case. - Java (I used jdk-11.0.13+8) - SQLcl Download Page or latest tarball
2

Installation (Zip)

We're going to install everything in our home directory, but you can put them anywhere.

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
9
# Install Java
mkdir ~/java
cd ~/java
tar -xf /tmp/OpenJDK11U-jdk_x64_linux_hotspot_11.0.13_8.tar.gz
ln -s ./j* ./latest

# Install SQLcl
cd ~
unzip -oq /tmp/sqlcl-21.3.2.287.1503.zip
3

Installation (RPM)

If you are using Oracle Linux on the Oracle Cloud Infrastructure (OCI) platform, you can install SQLcl directly from the Oracle Yum repository.

Code/Command (click line numbers to comment):

1
2
3
4
5
# OL7
yum install -y java-1.8.0-openjdk sqlcl

# OL8
dnf install -y java-1.8.0-openjdk sqlcl
4

Use It

To start SQLcl we need to make sure the environment variable is set, then run the "sql" script. I like to create an alias called "sql", but you could also put this location into your environment variable. Now we can run SQLcl as follows.

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
9
10
export JAVA_HOME=${HOME}/java/latest
alias sql="${HOME}/sqlcl/bin/sql"

sql /nolog

SQLcl: Release 21.3 Production on Fri Oct 29 10:42:24 2021

Copyright (c) 1982, 2021, Oracle.  All rights reserved.

SQL>
5

TNS_ADMIN

You can make connections to databases using the EZ Connect URL. If you would prefer to use a "tnsnames.ora" file, you can do that too. Just set the environment variable to the directory holding the file and it will work as expected. For example, imagine I had a "tnsnames.ora" file in my home directory with the following contents. I would do the following.

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
CONN scott/tiger@//myhost.example.com:1521/myservice

myservice= 
(DESCRIPTION = 
  (ADDRESS = (PROTOCOL = TCP)(HOST = myhost.example.com)(PORT = 1521))
  (CONNECT_DATA =
    (SERVER = DEDICATED)
    (SERVICE_NAME = myservice)
  )
)

export TNS_ADMIN=${HOME}

sql scott/tiger@myservice
6

Notes

You can get this error if you use an unsupported version of Java. The solution is to make sure the correct version of Java is being used. I've seen situations where the Java installation in the has taken priority over that in the JAVA_HOME location. It's also possible the PATH environment variable can confuse matters. If you are having problems, you might want to try the following. For more information see: - SQLcl : All Articles Hope this helps. Regards Tim...

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Exception in thread "main" java.lang.UnsupportedClassVersionError: oracle/dbtools/raptor/scriptrunner/cmdline/SqlCli : Unsupported major.minor version 52.0
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
        at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: oracle.dbtools.raptor.scriptrunner.cmdline.SqlCli.  Program will exit.

unset ORACLE_HOME
export JAVA_HOME=${HOME}/java/latest
export PATH=$JAVA_HOME/bin:$PATH

${HOME}/sqlcl/bin/sql

Comments (0)

Please to add comments

No comments yet. Be the first to comment!