Connect to Oracle database
--------------------------------------
//*** Sample 1: direct JDBC connection, classes12.zip is needed in the path
DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
conn= DriverManager.getConnection("jdbc:oracle:thin:@machine-or-url:1521:dbname",
"username", "password");
//1521 is port number
//*** Sample 2: JNDI connection (Used in JDeveloper or Oracle server)
InitialContext context = new InitialContext();
DataSource dcDS = (DataSource) context.lookup("jdbc/phl1096RadDS");
//Please Note: No 'DS' in configuration string.
conn = dcDS.getConnection();
-------------------------------------- |
Data source configuration screen in JDeveloper.
Enter proper values for Type, Authentication, and Connection.
.