Configuring Your Computer


Once you ve downloaded and installed the required software, your next step is to configure your computer to develop and run Java programs containing JDBC statements. You must set four environment variables on your machine:

  • ORACLE_HOME

  • JAVA_HOME (and J2EE_HOME if you re using Java 2 Enterprise Edition)

  • PATH

  • CLASSPATH (and J2EE_CLASSPATH if you re using Java 2 Enterprise Edition)

If you re using Unix or Linux, you ll also need to set the additional LD_LIBRARY_PAT H environment variable. You ll learn how to set these environment variables in the following sections.

Setting the ORACLE_HOME Environment Variable

The ORACLE_HOME directory is where you installed the Oracle software, and you ll need to set an environment variable named ORACLE_HOME on your machine that specifies this directory.

Setting an Environment Variable with Windows

To set an environment variable in Windows, you use the Environment Variables dialog box. To do this on Windows 2000, you perform the following steps:

  1. Open the Control Panel.

  2. Double-click System. This displays the System Properties dialog box.

  3. Select the Advanced tab.

  4. Click Environment Variables. This displays the Environment Variables dialog box.

Check if there s currently an ORACLE_HOME system variable defined, and if so, check that it s set to the directory where you installed the Oracle software. If there s no ORACLE_HOME defined, go ahead and create one by clicking New in the System Variables area. On my computer, ORACLE _HOME is set to E:\oracle\Ora10.

Setting an Environment Variable with Unix or Linux

To set an environment variable in Unix or Linux, you ll need to add additional lines to a special file, and the file you need to modify depends on which shell you re using. If you re using the Bourne or Korn shell, you add the following lines to your .profile file using the following syntax:

 ORACLE_HOME=  install_directory  export ORACLE_HOME 

You replace install_directory with the directory where you installed the Oracle software. If you re using the Bash shell with Linux, you use the same syntax but add the lines to your .bash_profile file. For example:

 ORACLE_HOME=/usr/local/oracle export ORACLE_HOME 

If you re using the C shell, you add the environment variable to your .login file using the following syntax:

 setenv ORACLE_HOME  install_directory  

For example:

 setenv ORACLE_HOME /usr/local/oracle 

Setting the JAVA_HOME Environment Variable

The JAVA_HOME environment variable specifies the directory where you installed your Java SDK. For example, if you installed the SDK in the E:\sdk directory, you need to set your JAVA_HOME variable to that directory using the steps I showed you in the previous section.

Note  

If you re using Java 2 Enterprise Edition, you need to also set J2EE _ HOME to the directory where you installed J2EE. Refer to Sun s documentation for further installation details.

Setting the PATH Environment Variable

The PATH environment variable contains a list of directories. When you enter a command using your operating system command line, the command searches the directories in your PATH for the executable specified. You ll probably already have a PATH set to some directories on your computer, and you need to add the following two directories to your existing PATH :

  • The bin subdirectory of the directory where you installed the Java SDK

  • The BIN subdirectory of the directory where you installed the Oracle software

For example, if you installed the SDK in the E:\sdk directory, and you installed the Oracle software in E:\oracle\Ora10, you would add E:\sdk\bin;E:\oracle\Ora10\BIN to your PATH . Notice the semicolon (;) that separates the two directories. To set the PATH in Windows 2000, use the same steps I showed you earlier.

To add to an existing PATH in Unix or Linux, you need to modify the appropriate file for your shell. For example, if you re using the Bash shell with Linux, add lines to your .bash_profile file that are similar to the following:

 PATH=$PATH:$JAVA_HOME/bin:$ORACLE_HOME/BIN export PATH 

Notice the colon (:) that separates the directories.

Setting the CLASSPATH Environment Variable

The CLASSPATH environment variable contains a list of locations where Java class packages are found. A location can be a directory name or the name of a Zip file or JAR file containing classes. The ORACLE_HOME\jdbc\lib directory contains a number of Zip files; which ones you add to your CLASSPATH depends on what Java SDK you re using and what features you need.

Note  

You must consult the Readme.txt file located in the ORACLE_HOME\jdbc directory for exact details on which Zip files to add to your CLASSPATH .

At time of writing, the following was correct for setting a CLASSPATH :

  • If you re using JDK 1.2. x (or higher), add classes12.zip to your CLASSPATH . If you need National Language support, also add nls_charset12.zip to your CLASSPATH .

  • If you re using JDK 1.1. x , add classes111.zip to your CLASSPATH . If you need National Language support, also add nls_charset11.zip to your CLASSPATH .

    Note  

    You also need to add the current directory to your CLASSPATH . You do this by adding a period ( . ) to your CLASSPATH . That way, the classes in your current directory will be found by Java when you run your programs.

A typical CLASSPATH for Windows 2000 might be:

 .;E:\oracle\Ora10\jdbc\lib\classes12.zip;E:\oracle\ Ora10\jdbc\lib\nls_charset12.zip 

If you re using Windows 2000, use the steps described earlier to set your CLASSPATH . If you re using Linux, you should add lines to your .bash_profile file similar to the following:

 CLASSPATH=$CLASSPATH:.:$ORACLE_HOME/jdbc/lib/classes12.zip: $ORACLE_HOME/jdbc/lib/nls_charset12.zip  export CLASSPATH 
Note  

If you re using Java 2 Enterprise Edition, you ll also need to set J2EE _ CLASSPATH . Refer to Sun s documentation for further installation details.

Setting the LD_LIBRARY_PATH Environment Variable

If you re using Unix or Linux, you ll also need to set the LD_LIBRARAY_PATH environment variable to $ORACLE_HOME/lib. This directory contains shared libraries that are used by the JDBC OCI driver.

That concludes configuring your computer; you ll learn about the Oracle JDBC drivers next.




Oracle Database 10g SQL
Oracle Database 10g SQL (Osborne ORACLE Press Series)
ISBN: 0072229810
EAN: 2147483647
Year: 2004
Pages: 217

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net