By Blaine Carter
By now you’ve probably heard about Oracle Autonomous Transaction Processing. If not, follow the link for more information.
One major feature of Oracle Autonomous Transaction Processing is enhanced security. For example, Oracle Autonomous Transaction Processing uses machine learning and automation to improve its own security, but it also takes advantage of an Oracle wallet. There are many ways you can use an Oracle wallet to enhance the security of database connections, but with Oracle Autonomous Transaction Processing, it is already set up, packaged, and ready to go.
I am going to walk you through the process of preparing to connect securely to your Oracle Autonomous Transaction Processing database instance with an Oracle wallet, followed by some code examples in a few languages you can use to test the connection.
Here are the prerequisites for following along with the steps in this article:
(DIRECTORY="/home/demouser/projects/ATP/Wallet_Creds")
Figure 1: Making the database connection
Figure 2: Downloading the client credentials
Figure 3: Creating a password for your client credentials
Now test the connection from your Oracle SQLcl or Oracle SQL Developer tool.
Oracle SQLcl. To test the connection from Oracle SQLcl, do the following:
sql /nolog
set cloudconfig /home/demouser/projects/ATP/Wallet_Creds/ client_credentials.zip Operation is successfully completed. Using temp directory:/tmp/oracle_cloud_config903805845690230771
connect myschema/mypassword@BlaineATP_MEDIUM Connected.
select 'Connected to Oracle Autonomous Transaction Processing from SQLcl!' "Test It" from dual; Test It ----------------------------------------------------------------- Connected to Oracle Autonomous Transaction Processing from SQLcl!
exit Disconnected from Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 – Production Version 18.4.0.0.0
Oracle SQL Developer. To test the connection from Oracle SQL Developer, do the following:
If the Oracle SQL Developer connection or query tests were a success, you know that your client credentials file is valid and that you are able to connect to the Oracle Autonomous Transaction Processing database instance.
Figure 4: Entering the connection name, username, password, connection type, configuration file, and service in Oracle SQL Developer
To connect to Oracle Autonomous Transaction Processing with most programming languages, do the following:
export TNS_ADMIN="/home/demouser/projects/ATP/Wallet_Creds" export OADB_USER='demo' export OADB_PW='demoPassword' export OADB_SERVICE='BlaineATP_MEDIUM' export OADB_CONNECTSTRING="$OADB_USER/$OADB_PW@$OADB_SERVICE"
Python. To connect to the Oracle Autonomous Transaction Processing database instance with Python, do the following:
import cx_Oracle import os con = cx_Oracle.connect(os.environ['OADB_USER'], os.environ['OADB_PW'], os.environ['OADB_SERVICE']) cur = con.cursor() cur.execute("select 'Connected to Oracle Autonomous Transaction Processing from Python!' from dual") res = cur.fetchall() for row in res: print(row) cur.close() con.close()
python python_demo.pyThe following response confirms your connection from Python to Oracle Autonomous Transaction Processing:
('Connected to Oracle Autonomous Transaction Processing from Python!',)
var oracledb = require('oracledb'); oracledb.getConnection({ user: process.env.OADB_USER, password: process.env.OADB_PW, connectString: process.env.OADB_SERVICE }, function(err, connection) { if (err) { console.error(err.message); return; } connection.execute( "select 'Connected to Oracle Autonomous Transaction Processing from Node.js!' from dual", function(err, result) { if (err) { console.error(err); return; } console.log(result.rows); }); });
node nodeDemo.jsThe following response confirms your connection from Node.js to Oracle Autonomous Transaction Processing:
[ [ 'Connected to Oracle Autonomous Transaction Processing from Node.js!' ] ]
Ruby. To connect to the Oracle Autonomous Transaction Processing database instance with Ruby, do the following:
require 'oci8' con = OCI8.new(ENV['OADB_USER'], ENV['OADB_PW'], ENV['OADB_SERVICE']); statement = "select 'Connected to Oracle Autonomous Transaction Processing from Ruby!' from dual"; cursor = con.parse(statement) cursor.exec cursor.fetch() {|row| printf "%s\n", row[0] }
ruby ruby-demo.rbThe following response confirms your connection from Ruby to Oracle Autonomous Transaction Processing:
Connected to Oracle Autonomous Transaction Processing from Ruby!
Go. To connect to the Oracle Autonomous Transaction Processing database instance with Go, do the following:
package main import ( "database/sql" _ "gopkg.in/goracle.v2" "fmt" "os" ) func main() { connectString := os.Getenv("OADB_CONNECTSTRING") db, err := sql.Open("goracle", connectString) if err != nil { panic(err) } defer db.Close() row := db.QueryRow("select 'Connected to Oracle Autonomous Transaction Processing from Go!' from dual") var strCol string err = row.Scan(&strCol) if err != nil { panic(err) } fmt.Printf("%s\n", strCol) }
go build goDemo.go ./goDemoThe following response confirms your connection from Go to Oracle Autonomous Transaction Processing:
Connected to Oracle Autonomous Transaction Processing from Go!
Other languages. Figure 5 contains a list of some of the Oracle Database drivers available for a few other languages—there are many more.
Figure 5: Oracle Database languages and drivers supported
I have not personally tested an Oracle Autonomous Transaction Processing connection with every one of the drivers in Figure 5, but the methods used in this article should work for all of them. If you have difficulty making the connection with one of these drivers, please reach out to me, and I will do my best to help make it work.LEARN more about Oracle Autonomous Transaction Processing.
TRY Oracle Autonomous Transaction Processing.
Illustration by Wes Rowell
DISCLAIMER: We've captured these popular historical magazine articles for your reference. Links etc contained within these article possibly won't work. These articles are provided as-is with no guarantee that the information within them is the best advice for current versions of the Oracle Database.