Skip Headers

Oracle9i OLAP Developer's Guide to the OLAP API
Release 2 (9.2)

Part Number A95297-01
Go To Documentation Library
Home
Go To Product List
Book List
Go To Table Of Contents
Contents
Go To Index
Index

Master Index

Feedback

Go to previous page Go to beginning of chapter Go to next page

Connecting to a Data Store, 3 of 6


Establishing a Connection

To make a connection, perform the following steps:

  1. Load the JDBC driver that you will use.
  2. Get a Connection from the DriverManager.
  3. Create a TransactionProvider.
  4. Create a DataProvider.

These steps are explained in more detail in the rest of this topic.

Note that the TransactionProvider and DataProvider objects that you create in these steps are the ones that you use throughout your work with the data store. For example, when you create certain Source objects, you use methods on this DataProvider object.

Step 1: Load the JDBC Driver

The following line of code loads a JDBC driver and registers it with the JDBC DriverManager.

Example 3-1 Loading the JDBC Driver for a Connection

Class.forName("oracle.jdbc.driver.OracleDriver");

After the driver is loaded, you can use the DriverManager object to make a connection. For more information about loading Oracle's JDBC drivers, see the Oracle9i JDBC Developer's Guide and Reference.

Step 2: Get a Connection from the DriverManager

The following code gets a JDBC Connection object from the DriverManager.

Example 3-2 Getting a JDBC Connection

String url = "jdbc:oracle:thin:@lab1:1521:orcl";
String user = "hepburn";
String password = "tracey";
oracle.jdbc.OracleConnection conn = (oracle.jdbc.OracleConnection)
   java.sql.DriverManager.getConnection(url, user, password); 

This example connects user hepburn with password tracey to a database with SID (system identifier) orcl. The connection is made through TCP/IP listener port 1521 of host lab1. The connection uses the Oracle JDBC thin driver.

There are many ways to specify your connection characteristics using the getConnection method. See the Oracle9i JDBC Developer's Guide and Reference for details.

After you have the Connection object, you can create the required OLAP API objects, TransactionProvider and DataProvider.

Step 3: Create a TransactionProvider

TransactionProvider is an OLAP API interface. Therefore, in your code, you use an instance of the concrete class called ExpressTransactionProvider. The following line of code creates a TransactionProvider.

Example 3-3 Creating a TransactionProvider

ExpressTransactionProvider tp = new ExpressTransactionProvider();

A TransactionProvider is required for creating a DataProvider.

Step 4: Create a DataProvider

DataProvider is an OLAP API abstract class. Therefore, in your code, you use an instance of the concrete subclass called ExpressDataProvider. The following lines of code create and initialize a DataProvider.

Example 3-4 Creating a DataProvider

ExpressDataProvider dp = new ExpressDataProvider(conn, tp);
dp.initialize();

A DataProvider is required for creating a MetadataProvider, which is described in Chapter 4, "Discovering the Available Metadata"


Go to previous page Go to beginning of chapter Go to next page
Oracle
Copyright © 2000, 2002 Oracle Corporation.

All Rights Reserved.
Go To Documentation Library
Home
Go To Product List
Book List
Go To Table Of Contents
Contents
Go To Index
Index

Master Index

Feedback