COMP3150
download
To ensure you have all the required libraries for JDBC:OCI applications, install the Basic Package from the Oracle Instant Client Downloads. There are several versions to choose from, but the latest version will work.
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
|
|
You will also need to be connected to the campus VPN to be able to connect using port 1521.
|