Database

How to run Oracle SQLcl client directly as a Java class (skip sql.exe)?

Oracle SQL Developer Command Line (SQLcl) is a free command line interface for Oracle Database. It allows you to interactively or batch execute SQL and PL/SQL. SQLcl provides in-line editing, statement completion, and command recall for a feature-rich experience, all while also supporting your previously written SQL*Plus scripts.

Here is what is said about this tool by Oracle. As an old good “SQL*Plus”, this tool is extremely valuable for database setup, migration, maintenance scripts. Moreover, it may satisfy any needs for Oracle database.

Sometimes there are circumstances, which does not allow you to execute .exe files in some protected operating systems. It depends on what security tools and level is used, sometimes its no problem to run java classes directly. So here is just command line which can be executed to run SQLcl as a Java class

java -cp <path_to_SQLcl_lib_directory> oracle.dbtools.raptor.scriptrunner.cmdline.SqlCli <db_schema_name>/<db_schema_password>@<db_hostname>:<db_port>/<db_sid>

For example if your current directory is SQLcl, which has lib directory inside, sample command could look like this:

java -cp lib/* oracle.dbtools.raptor.scriptrunner.cmdline.SqlCli scott/scott@localhost:1521/xe

SQLcl version 19.2.1

 

 

About Danas Tarnauskas