| Oracle9i OLAP Developer's Guide to the OLAP API Release 2 (9.2) Part Number A95297-01 |
|
Connecting to a Data Store, 3 of 6
To make a connection, perform the following steps:
Connection from the DriverManager.TransactionProvider.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.
The following line of code loads a JDBC driver and registers it with the JDBC DriverManager.
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.
The following code gets a JDBC Connection object from the DriverManager.
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.
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.
ExpressTransactionProvider tp = new ExpressTransactionProvider();
A TransactionProvider is required for creating 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.
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"
|
![]() Copyright © 2000, 2002 Oracle Corporation. All Rights Reserved. |
|