Perl Cd Bookshelf [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Perl Cd Bookshelf [Electronic resources] - نسخه متنی

Mark V. Scardina, Ben ChangandJinyu Wang

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید






Using the XDK with Oracle JDeveloper


Oracle JDeveloper has added more XML functionality with each release. At the time of this writing, Oracle JDeveloper 10g has just been released, so this section is current to that version. Every version has included the Oracle XDK’s Java libraries, and each version has seen them better integrated. Regardless of the version you are using, the content in this section will be applicable unless specifically stated otherwise.


Setting Up an XDK Environment


Each Java project in JDeveloper has a set of properties that can be accessed by right-clicking the project filename in the Navigator window and selecting Project Properties. Project files are identified by a .jpr extension. Select Libraries to display the dialog box shown in Figure 13-2.


Figure 13-2: Selecting your project properties’ libraries

Since Oracle JDeveloper includes the Oracle XDK’s Java libraries, you already have entries for them. Should you wish to add newer versions, you can easily add them by clicking New or Edit and defining a different library name from existing ones. While you will not have the path to the source code, you can download the Javadocs for the newer libraries from OTN and provide their path for easy use within the IDE.

The other use of the Libraries dialog box is to indicate what libraries are missing when compiling or deploying a project. This is especially true for imported projects. Missing libraries will be indicated in red and you can resolve them simply by either adding a new one or editing it so that it refers to the local library.


Setting Up a Database Connection


JDeveloper has the functionality to connect to a database for run-time access; however, this connection must be configured globally before you can use it. Access to this configuration is not intuitive, so the following are the instructions. However, before you start you should have a database instance running and the user ID, password, and optionally the role you want to use to connect.

Types of JDBC Drivers


One additional important preparation step is to ensure that JDeveloper knows about the Oracle Database 10g JDBC drivers. This is important because, starting in this release, the naming convention has changed. JDeveloper comes configured for version 9 JDBC drivers, which, while they will work against Oracle Database 10g, will have poorer performance and will not have support for all the features. The following sections describe the JDBC drivers included in your ORACLE_HOME/jdbc/lib directory along with their dependencies and purpose.

JDBC Thin Driver 10.1.0.2.0


This is a 100 percent Java driver designed for client applications, midtier servers, and applets. It is contained within classes12.jar for use with JDK 1.2 and 1.3 and contained within ojdbc14.jar for use with 1.4. If you require complete NLS support for objects and collection types, you also need orai18n.jar. This driver will not support XMLType on the client. The connection string is

Connection conn = DriverManager.getConnection(
"jdbc:oracle:thin:@<database>",
"my_user", "my_password");

where <database> is either a string of the form host:port:sid, a SQL*NET name-value pair, or a service name.

JDBC OCI Driver 10.1.0.2.0


This is the “thick” Java driver that utilizes OCI to provide client-side full datatype support, including XMLType. It is contained within classes12.jar for use with JDK 1.2 and 1.3 and contained within ojdbc14.jar for use with 1.4. If you require complete NLS support for objects and collection types, you also need orai18n.jar. On Windows, you also need to have ORACLE_HOME\bin in your PATH to locate the needed C libraries. The connection string is

Connection conn = DriverManager.getConnection(
"jdbc:oracle:oci:@<database>",
"my_user", "my_password");

where <database> is either an entry in tnsnames.ora or a SQL*NET name-value pair.

JDBC Server-Side Internal Driver 10.1.0.2.0


This is the internal JDBC driver that runs in the OJVM in the database. It is also known as the kprb JDBC driver. All classes and libraries are already loaded for it to work supporting all data types. The connection string is

Connection conn = DriverManager.getConnection(
"jdbc:oracle:kprb:");

Note that the trailing “;” is necessary.

Creating a Database Connection


To create a database connection, first select File | New to open the New Gallery dialog box. Expand the General category and select Connections, as shown in Figure 13-3. In the list of items on the right side, double-click Database Connection. This starts the Database Connection Wizard. The same wizard can also be triggered from the Connection Navigator, by right-clicking the Database Connection node and selecting the New Database Connection shortcut menu.


Figure 13-3: JDeveloper database connection selection


Select OK on the first wizard page to go to Step 1, which allows you to name the connection (for example, DBConnection10g). At this point, the Connection Type drop-down list box enables you to select the type of JDBC driver you want to use. To use either the thin or thick JDBC driver, select Oracle (JDBC), which takes you to the Authentication step to enter your login information (e.g., SYS, ORACLE, SYSDBA). Check Deploy Password to avoid the password prompt each time you connect. Click Next to go to the Connection step, where you select either the thin or oci8 (thick) driver along with the Hostname, JDBC Port, and SID (e.g., localhost, 1521, ORCL).

Select Next to go to the final Test step, which lets you test the JDBC connection. If your setup is correct, you will see “Success!” displayed; otherwise, you will see the error you need to correct. Even if you plan to use the thick driver to get full XMLType support, if you get an error, we suggest that you try the thin connection because that will confirm that your database parameters and strings are correct.

When you create connections using Oracle’s JDBC/OCI drivers, be aware of the following platform-specific requirements:



You must have the required native libraries (DLL files on Windows, and SO/SL files on UNIX). With the Oracle thick driver (JDBC/OCI), the version of the JDBC driver must match the version of the Oracle Home. For example, the Oracle JDBC Driver version 10.1.0 requires that the Oracle Home contain version 10.1.0 of the ocijdbc10.dll, as well as the Oracle Network software and supporting libraries, message files, encodings, etc., within an Oracle Home. If you are connecting to a local database that is a different version from the JDBC driver you are using, then you must install the Oracle client software into a separate Oracle Home, and connect via the Oracle Net Listener.



You must place the ORACLE_HOME directory in which the client-side files for the required native libraries reside in your PATH environment variable. On Windows, you need the %ORACLE_HOME%\bin directory in which the client-side DLL files reside in your PATH environment variable. If you have multiple Oracle Homes installed on your machine, use the Oracle Home Switch utility to choose the correct Oracle Home. On UNIX, you need the $ORACLE_HOME/lib directory in which the client-side SO/SL files reside in your PATH environment variable.



If your Oracle Home for the OCI driver is not the same as the Oracle Home in which JDeveloper is installed, you must either set the ORACLE_HOME environment variable or edit /jdev/bin/jdev.conf with a line similar to the following, replacing the path shown with the full path to your Oracle Home:



On Windows: “AddNativeCodePath C:\ORACLE\ORA10\BIN”



On UNIX: “AddNativeCodePath /u01/app/oracle/product/10.1.0/lib”



This command allows JDeveloper to properly update the java.library.path in which the Java VM searches for shared libraries. Connections set up this way are available globally and are automatically available to your projects.


Creating an XDK Component Palette


Oracle XDK 10g includes a collection of XML JavaBeans that can be easily integrated into JDeveloper as an XDK palette. You can add pages to the Component Palette to group your XDK JavaBeans components, or you can add components to existing pages. Once you add JavaBeans to the palette, you can insert them into any file you have open in the UI Editor by selecting them from the Component Palette.

The XDK JavaBeans are contained in xml.jar and xmlparserv2.jar; therefore, you need to first make sure JDeveloper knows about these JARs. Select Tools | Manage Libraries to display a listing of User Libraries, Addin Libraries, and System Libraries. Selecting any one will allow you to add a new library to the list by clicking New. Enter XDK Components for Library Name and edit the Class Path to point to the location at, for example, C:\oracle\ora10\lib\xml.jar. Leave the Source Path and Doc Path blank unless you downloaded the Javadocs from OTN. Click OK and you are done.

To create an XDK JavaBeans Component Palette, follow these steps:



From the main menu, select Tools | Configure Palette to open the Configure Component Palette dialog box.



Click Add to open the New Palette Page dialog box.



Enter a page name, such as XDK JavaBeans, and click OK. You now see your new entry highlighted in the Configure Component Palette dialog box.



Click Add on the Components side, and an Add JavaBeans dialog box will appear with a picklist of register libraries.



Select XDK Components, and for the filter, select JavaBeans with BeanInfo Only from the Filter drop-down list. Expanding the oracle.xml class tree displays the list shown in Figure 13-4.


Figure 13-4: Adding a JavaBeans XDK Components list



You can now select the DBAccess, XSDValidator, XMLDiffer, XMLDBAccess, and XMLCompress JavaBeans by clicking each and then clicking OK.





Note

Although you can select multiple Beans by holding down the CTRL key, the associated Bean images will not be correctly assigned.




Once you have completed these, you can add the DOMBuilder and XSLTransformer JavaBeans from xmlparserv2.jar, giving you seven JavaBeans, as shown in Figure 13-5.


Figure 13-5: XDK Component Palette

This palette now is available whenever you activate the Component Palette from View | Component Palette for all Java programs. You can drag and drop its components onto Swing or AWT panels when using the UI Designer of JDeveloper.

/ 218