Oracle
ORACLE
Oracle database is installed
Connecting to Oracle server from Delta using jdbc
CS Oracle database server connections
JDBC Connection string
In the connection strings below, replace "userid" with your UWinID, and "password" with your campus password.
Code to test your connection:
import java.sql.*;
import oracle.jdbc.*;
import oracle.jdbc.pool.OracleDataSource;
class JDBCVersion
{
public static void main (String args[]) throws SQLException
{
OracleDataSource ods = new OracleDataSource();
ods.setURL("jdbc:oracle:thin:userid/password@oracle.cs.uwindsor.ca:1521:cs01");
Connection conn = ods.getConnection();
// Create Oracle DatabaseMetaData object
DatabaseMetaData meta = conn.getMetaData();
// gets driver info:
System.out.println("JDBC driver version is " + meta.getDriverVersion());
}
}
The classpath for the Oracle JDBC archive will vary depending on the operating system and which version of the Oracle client you installed. The classpath in the following commands are those required to compile and run from a terminal on cs.uwindsor.ca.
javac -classpath /usr/lib/oracle/12.1/client64/lib/ojdbc7.jar JDBCVersion.java java -classpath /usr/lib/oracle/12.1/client64/lib/ojdbc7.jar:. JDBCVersion
Connecting to Oracle server from Delta using Python
Use the following code db_config.py
import cx_Oracle
import sys
import os
import getpass
user = os.getlogin()
dsn = os.environ.get("PYTHON_CONNECT_STRING", "oracle.cs.uwindsor.ca/cs01")
pw = os.environ.get("PYTHON_PASSWORD")
if pw is None:
pw = getpass.getpass("Enter password for %s: " % user)
Using the following code, you connect to the database
import cx_Oracle
import db_config
con = cx_Oracle.connect(db_config.user, db_config.pw, db_config.dsn)
print("Database version:", con.version)
Run the Code: before running the code, set the environment variables using export
Check the following URL for more information: Tutorial cx_OracleYou embed the export in shell script and call your Python code from the same script