2023-07-16

SQLcl stores connections - how and where?

Oracles SQLcl has a lot of nice features. One is to store connections (connection_string, username and  password - if you choose to). But - as normal - there is little information how and where it is stored. 

First I create a new connection in my brand new 23.2 SQLcl: 


sql -nolog


SQLcl: Release 23.2 Production on Sun Jul 16 17:53:37 2023

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

No Connection
SQL> connect berx/berx@//127.0.0.1/freepdb1
Connected.
SQL> conn -save berxfree -savepwd
Name: berxfree
Connect String: //127.0.0.1/freepdb1
User: berx
Password: ******
SQL> connmgr list
berxfree
SQL> connmgr show berxfree
Name: berxfree
Connect String: //127.0.0.1/freepdb1
User: berx
Password: ******
SQL>

I found the connection definition in a subdirectory of  ~/.dbtools/connections/

[oracle@localhost connections]$ pwd
/home/oracle/.dbtools/connections
[oracle@localhost connections]$ ls -la
total 0
drwx------. 3 oracle oinstall 22 Jul 16 17:54 .
drwx------. 3 oracle oinstall 25 Jul 15 16:34 ..
drwx------. 2 oracle oinstall 51 Jul 16 17:54 berxfree
[oracle@localhost connections]$
And in this directory I have 2 files: cwallet.sso dbtools.properties

First let's check the dbtools.properties:

#
#Sun Jul 16 17:54:23 UTC 2023
connectionString=//127.0.0.1/freepdb1
name=berxfree
type=ORACLE_DATABASE
userName=berx


also the cwallet.sso has some valuable content:

[oracle@localhost berxfree]$ mkstore -wrl . -list
Oracle Secret Store Tool Release 23.2.0.0.0 - Production
Version 23.2.0.0.0
Copyright (c) 2004, 2023, Oracle and/or its affiliates. All rights reserved.

Oracle Secret Store entries:
oracle.security.client.connect_string1
oracle.security.client.password1
oracle.security.client.username1
[oracle@localhost berxfree]$ mkstore -wrl . -viewEntry oracle.security.client.connect_string1
Oracle Secret Store Tool Release 23.2.0.0.0 - Production
Version 23.2.0.0.0
Copyright (c) 2004, 2023, Oracle and/or its affiliates. All rights reserved.

oracle.security.client.connect_string1 = //127.0.0.1/freepdb1
[oracle@localhost berxfree]$ mkstore -wrl . -viewEntry oracle.security.client.password1
Oracle Secret Store Tool Release 23.2.0.0.0 - Production
Version 23.2.0.0.0
Copyright (c) 2004, 2023, Oracle and/or its affiliates. All rights reserved.

oracle.security.client.password1 = berx

It should be obvious by now the wallet is auto open - so no password is needed (and my credentials password isn't very secure). 

Btw: if you omit the -savepwd parameter, there will be still a cwallet.sso - but it's simply empty. All the other connection parameters are in dbtools.properties already. 


Of course, sometimes I have to use Windows. There is nothing like ~/.dbtools. The directory is more visible in %HOMEDRIVE%%HOMEPATH%\DBTools. This is especially valuable as I can copy the berxfree subdirectory from my linux sandbox to the Windows laptop into %HOMEDRIVE%%HOMEPATH%\DBTools\connections and just use it - simple like that.  
 
That's nearly all to share here - just in case you want to remove a stored connection, delete it's directory and all is gone!

Keine Kommentare: