18.3 Installing and Configuring Oracle9i Database

18.3 Installing and Configuring Oracle9i Database

Oracle9i Database is a high-volume, production database deployed in many corporate enterprises for both Internet and intranet applications. Oracle9i Database provides all the functionality you would expect in a production database server, including stored procedures, views, triggers, enhanced security, and data recovery.

Three different editions of Oracle9i Database Release 2 are available from Oracle, as described below. Oracle9i includes a large family of products (including Oracle9i Application Server and Oracle9i Developer Suite), but in the remaining sections we use "Oracle9i" to refer to Oracle9i Database.

  • Enterprise Edition. Oracle9i Enterprise Edition delivers an efficient, reliable solution for both Internet and intranet applications. The Enterprise Edition is suitable for high-volume transaction processing and data warehousing. The Enterprise Edition includes a preconfigured database, networking services, database management tools, and utilities. In addition, multiple product options are licensable with the Enterprise Edition.

  • Standard Edition. Oracle9i Standard Edition is a scaled-down version of the Enterprise Edition and can be licensed only for servers with a maximum of four processors. The Standard Edition is suitable for workgroup, department, intranet, and Internet applications. The Standard Edition includes a preconfigured database, networking services, database management tools, and utilities; however, the Standard Edition does not support all features available in the Enterprise Edition.

  • Personal Edition. Oracle9i Personal Edition is suitable for a single- user , desktop environment. The Personal Edition is intended for educational purposes, providing a cost-effective , yearly licensing fee. The Personal Edition supports all the features and options available in the Enterprise Edition, with the exception of Oracle Real Application Clusters.

For a more detailed summary of the three Oracle9i Database editions, see http://otn.oracle.com/products/oracle9i/pdf/9idb_rel2_prod_fam.pdf.

To use Oracle9i, you must install the product, set up a database, and configure users' rights. In this section we provide information for downloading and installing Oracle9i Release 2 on Windows XP. For other platforms, you can find platform-specific installation instructions at http://otn.oracle.com/docs/products/oracle9i/. Below, we outline the four steps required to set up an Oracle9i, followed by a detailed description of each step.

  1. Download and install Oracle9i. Download Oracle9i Database Release 2 from http://otn.oracle.com/software/products/oracle9i/ and install by using the Oracle Universal Installer.

  2. Create a database. Typically, a database is created during the installation of Oracle9i; however, if Oracle9i is already installed on the computer you are using, you can create a new database manually or use the Database Configuration Assistant.

  3. Create a user. To access the database from a Web application, you need to create a new user and then grant connection and table rights to the user.

  4. Install the JDBC driver. To access an Oracle database from a Web application, download the appropriate JDBC driver from http://otn.oracle.com/software/tech/java/sqlj_jdbc/. During development, include the JAR file in your CLASSPATH . For deployment, place the JAR file in the WEB-INF/lib directory of your Web application.

Download and Install Oracle9i

You can download Oracle9i Database Release 2 from http://otn.oracle.com/software/products/oracle9i/. A registration is required for download of Oracle software; however, the registration is free. Be sure to read the license agreement if you plan on using Oracle9i for production purposes. Oracle products are free to download for a 30-day evaluation period. After 30 days, you must purchase a license.

In the following instructions, we show you how to install Oracle9i Database Release 2 Personal Edition on the Windows XP platform. For installation instructions for other platforms, see the documentation at http://otn.oracle.com/docs/products/oracle9i/.

Oracle9i Database Release 2 for Windows NT/2000/XP is bundled in three ZIP files : 92010NT_Disk1.zip (612,802,971 bytes), 92010NT_Disk2.zip (537,604,934 bytes), and 92010NT_Disk3.zip (254,458,106 bytes). The same install files are used for the Enterprise, Standard, and Personal editions. Follow the instructions on the download page and unzip the three files into corresponding directories named Disk1 , Disk2 , and Disk3 . Alternatively, instead of downloading the software, you can purchase a CD pack at http://oraclestore.oracle.com/.

Oracle recommends the following minimum hardware requirements: Pentium 266, 256 Mbytes of RAM, and approximately 3 Gbytes of disk space for an NTFS partition. Exact requirements are available at http://otn.oracle.com/docs/products/oracle9i/doc_library/release2/A95493-01/html/reqs.htm.

Following are the instructions to install Oracle9i Database Personal Edition on the C:\ drive of a Windows XP computer. To perform this installation, you must log in to the machine with local administrator rights.

Core Warning

graphics/bwopenglobe_icon.gif

To install Oracle9i on Windows NT/2000/XP, you must have local administrator rights on the machine.


Steps to Install Oracle9i
  1. Start the Oracle Universal Installer. You can start the Oracle Universal Installer 2.2 from the setup.exe program located in the Disk1 directory. If the installer fails to start, try the setup.exe program located in the Disk1\install\win32 directory. When you start the installer, you will momentarily see the copyright screen, followed by a Welcome screen as shown Figure 18-5. Click the Next button.

    Figure 18-5. Second Oracle install window: Welcome message.

    graphics/18fig05.jpg

  2. Specify file locations. On the third screen displayed (Figure 18-6), you specify the location of the installation program and the directory on which to install Oracle9i. Accept the default values. The Oracle Home, OraHome92 , is used in the name for all Oracle services created during the installation process. Click Next to continue.

    Figure 18-6. Third Oracle install window: summarizes the location of source and destination files for the installation process.

    graphics/18fig06.jpg

  3. Select a product to install. On the fourth screen displayed (Figure 18-7), you select which product to install. Accept the default product, Oracle9i Database, and then click Next.

    Figure 18-7. Fourth Oracle install window: for selecting a product to install.

    graphics/18fig07.jpg

  4. Select the installation type. On the fifth screen displayed (Figure 18-8), you select the database edition to install. For a single-user environment, we recommend the Personal Edition, which requires 2.53 Gbytes of disk space on Windows XP. For more details on the three editions, see http://otn.oracle.com/products/oracle9i/pdf/9idb_rel2_prod_fam.pdf. Click Next.

    Figure 18-8. Fifth Oracle install window: for selecting an installation type. For a single user, select the Personal Edition.

    graphics/18fig08.jpg

  5. Select a database configuration. On the sixth screen displayed (Figure 18-9), you specify the database configuration. We recommend the default selection, General Purpose, because the installation process for this selection automatically creates a starter database. Accept the default database configuration and click Next.

    Figure 18-9. Sixth Oracle install window: for selecting a database configuration.

    graphics/18fig09.jpg

  6. Specify the port for the Oracle MTS Recovery Service. On the seventh screen displayed (Figure 18-10), you specify the port for the Oracle MTS Recovery Service, which is automatically installed with Oracle Services for Microsoft Transaction Server. This service helps resolve requests for distributed transaction coordinated by the Microsoft DTC (MS DTC exposes COM objects that allow clients to initiate and participate in coordinated transactions across multiple connections to various data stores). You might not use this capability, so simply accept the default port number of 2030 and click Next.

    Figure 18-10. Seventh Oracle install window: for specifying a port for the Oracle MTS Recovery Service.

    graphics/18fig10.jpg

  7. Provide a database system identification (SID). On the eighth screen displayed (Figure 18-11), you uniquely identify your database. Oracle configuration and utility tools use the SID to identify the database to operate upon. For the JDBC examples presented in this book, we suggest a Global Database Name of csajsp.coreservlets.com. Entering this name will autogenerate a SID of csajsp . Click Next.

    Figure 18-11. Eighth Oracle install window: for specifying the name of the global database and SID.

    graphics/18fig11.jpg

  8. Specify a database location. The ninth screen displayed (Figure 18-12) defines the physical location of the database. In a production environment, Oracle recommends placing the database on a disk other than the one on which the Oracle9i software is installed. In a development environment, you might have only a single disk available. We used the default suggested location, C:\oracle\oradata . Click Next.

    Figure 18-12. Ninth Oracle install window: for specifying the physical location of the database.

    graphics/18fig12.jpg

  9. Specify a default character set. On the tenth screen displayed (Figure 18-13), you select a character set for your database. Accept the default character set in accordance with the language setting of the operating system.

    Figure 18-13. Tenth Oracle install window: for selecting the default character set to use for the database.

    graphics/18fig13.jpg

  10. Review list of products. The eleventh screen displayed (Figure 18-14) summarizes which Oracle products are about to be installed on the computer. After reviewing this list, click the Install button.

    Figure 18-14. Eleventh Oracle install window: summarizes the products to be installed on the computer.

    graphics/18fig14.jpg

  11. Install Oracle9i. At this point, the Oracle Universal Installer will install Oracle9i. The installer (Figure 18-15) indicates the progress of the installation and provides a brief message about each component as it is installed. All installation activity is recorded to a log file located at C:\Program Files\Oracle\Inventory\logs . You can examine the log file for details if the installation fails.

    Figure 18-15. Twelfth Oracle install window: during the installation of the Oracle components .

    graphics/18fig15.jpg

  12. Install configuration tools. After the core Oracle9i software is installed, you can optionally install configuration tools to manage your database. We recommend that you install the configuration tools. Click Next. Progress of the tool installations is indicated by the Oracle Universal Installer, as shown in Figure 18-16.

    Figure 18-16. Thirteenth Oracle install window: during the installation of configuration tools.

    graphics/18fig16.jpg

  13. Specify passwords. After the configuration tools are installed, the Database Configuration Assistant will prompt you for new SYS and SYSTEM passwords to manage the database (Figure 18-17). The default passwords used in many Oracle database products are change_on_install for SYS and manager for SYSTEM . Don't use these commonly known passwords. After specifying new passwords, click OK.

    Figure 18-17. Fourteenth Oracle install window: for specifying passwords. Use the Database Configuration Assistant to specify a password for the SYS and SYSTEM administrative accounts.

    graphics/18fig17.jpg

    Core Warning

    graphics/bwopenglobe_icon.gif

    The default passwords for the SYS and SYSTEM administrative accounts are commonly known. For secure administration of your database, specify different passwords.

  14. Complete the installation. The last screen displayed (Figure 18-18) is the end of the installation process. At this point, Oracle9i Database Release 2 is successfully installed on your computer with a starter database named csajsp . Click Exit to end the Oracle Universal Installer program.

    Figure 18-18. Fifteenth Oracle install window: completes the installation of Oracle9i.

    graphics/18fig18.jpg

Create a Database

Typically, you would create a starter database during installation of Oracle9i. However, if Oracle9i is already installed on the computer you are using, you may want to create a new database. You have two choices for creating a new database. The first choice is to use the Oracle Database Configuration Assistant, which is a graphical configuration tool. The second choice is to manually create the database. To give a better understanding of Oracle9i, we present both approaches for creating a new database. As with the Oracle9i installation, you must have local Windows administrative rights to create a new database.

Core Warning

graphics/bwopenglobe_icon.gif

To create a new Oracle9i database on Windows NT/2000/XP, you must have local administrator rights on the machine.


Create a Database with the Configuration Assistant

The process to create a new database is complicated, so Oracle strongly recommends using the Database Configuration Assistant (DBCA). Following are the steps to create a database with the DBCA.

  1. Start the Oracle Database Configuration Assistant. The DBCA is included with the Oracle9i database installation. To start the DBCA on Windows XP, from the Start menu, select Start, then Programs, then Oracle - OraHome92, then Configuration and Migration Tools, and last, Database Configuration Assistant. When the DBCA starts, a Welcome screen is displayed, as shown in Figure 18-19. Click Next.

    Figure 18-19. First DBCA window: Welcome message.

    graphics/18fig19.jpg

  2. Select an operation. On the second screen displayed (Figure 18-20), you select an operation to perform. Select the first option: Create a database. Click Next.

    Figure 18-20. Second DBCA window: for selecting an operation to perform.

    graphics/18fig20.jpg

  3. Select a database template. On the third screen displayed (Figure 18-21), you select a template for creating the database. Select the template for a new database. Click Next.

    Figure 18-21. Third DBCA window: for selecting a database template.

    graphics/18fig21.jpg

  4. Provide a database identification. On the fourth screen displayed (Figure 18-22), you specify a Global Database Name and SID to identify your new database. Oracle configuration and utility tools use the SID to identify the database to operate upon. For the JDBC examples presented in this book, we suggest a Global Database Name of csajsp.coreservlets.com. Entering this choice will autogenerate a SID of csajsp . Click Next.

    Figure 18-22. Fourth DBCA window: for specifying the name of the global database and SID.

    graphics/18fig22.jpg

  5. Select the database features to install. On the fifth screen displayed (Figure 18-23), you select the features you want to configure for use in your database. To create a simple database for testing, you do not need the optional features; uncheck each of them. If you are prompted with a question to confirm deletion of an associated tablespace, answer Yes. Also, select the Standard database features button and uncheck the four options. Click Next.

    Figure 18-23. Fifth DBCA window: for selecting the database features to install.

    graphics/18fig23.jpg

  6. Select a database connection option. On the sixth screen displayed (Figure 18-24), you select the mode in which you want your database to operate. Select the Dedicated Server Mode option. Click Next.

    Figure 18-24. Sixth DBCA window: for selecting the operational mode of the database.

    graphics/18fig24.jpg

  7. Specify initialization parameters. On the seventh screen displayed (Figure 18-25), you can customize the database. The default parameters are sufficient, so you don't need to customize any of the tab settings. Click Next.

    Figure 18-25. Seventh DBCA window: for specifying database initialization parameters.

    graphics/18fig25.jpg

  8. Specify storage parameters. On the eighth screen displayed (Figure 18-26) you specify storage parameters for the database creation. The default storage files and locations are sufficient and require no modification. Click Next.

    Figure 18-26. Eighth DBCA window: for specifying database storage parameters.

    graphics/18fig26.jpg

  9. Select database creation options. On the ninth screen displayed (Figure 18-27), you specify the database creation options. Here, you simply want to create a new database, so check the Create Database option. Click Next.

    Figure 18-27. Ninth DBCA window: for selecting database creation options.

    graphics/18fig27.jpg

  10. Review the database configuration. At this point, the DBCA presents a summary of all the selected options to create the database, as shown in Figure 18-28. After you have reviewed the options, click OK.

    Figure 18-28. Tenth DBCA window: summarizes the configuration options before the database is created.

    graphics/18fig28.jpg

  11. Monitor the database creation process. The eleventh screen displayed (Figure 18-29) indicates activities as the database is created. You can monitor this process if so desired.

    Figure 18-29. Eleventh DBCA window: during the creation of the database.

    graphics/18fig29.jpg

  12. Specify passwords. After the database is installed, the Database Configuration Assistant will prompt you for SYS and SYSTEM passwords to manage the database (Figure 18-30). After specifying new passwords, click OK to complete the database creation process.

    Figure 18-30. Twelfth DBCA window: for specifying the SYS and SYSTEM administrative passwords.

    graphics/18fig30.jpg

Create a Database Manually

You usually use the Database Configuration Assistant (described in the previous subsection) to create new databases. However, for more complete control of the process, you occasionally want to do it manually. This section describes that manual process. The following list briefly outlines the steps to manually create an Oracle9i database. Detailed instructions follow the list.

  1. Set up database directories. Before you can create a new database, you must first set up the necessary directories for both administrative and database files.

  2. Create an initialization parameter file. An initialization parameter file is required for configuration and startup of the database. In addition to other information, the parameter file contains information about the block size and the number of processes permitted.

  3. Create a password file. A password file containing user authorization information is required for management of the database. Administrators can be authenticated either through a password file or through OS system groups. For this configuration, we use a password file.

  4. Create a service for the database. On Windows NT/2000/XP, the database runs as a service. This approach prevents the database from shutting down when the administrator logs off the computer.

  5. Declare the ORACLE_SID value. The ORACLE_SID is an environment variable to declare which database to use when running Oracle tools, such as SQL*Plus.

  6. Connect to the Oracle service as SYSDBA . To manage and create a database from SQL*Plus, you must connect to the Oracle service as the system database administrator ( SYSDBA ).

  7. Start the database instance. Starting the instance initializes the memory and processes to permit creation and management of a database. If the database instance is not started, the database cannot be created.

  8. Create the database. Issue a command in SQL*Plus to create the database, allocating log and temp files.

  9. Create a user tablespace. The tablespace stores the tables created by a user of the database.

  10. Run scripts to build data dictionary views. Two scripts, catalog.sql and catproc.sql , must be run to set up views and synonyms in the database. The first script, catproc.sql , also configures the database for use with PL/SQL.

Next, we provide detailed information about each step.

Set Up Database Directories

Before creating a new database, set up the directories for both the administrative and database files. Assuming that Oracle9i is installed on the C:\ drive, create the following directories:

 
 C:\oracle\admin\csajsp C:\oracle\admin\csajsp\bdump C:\oracle\admin\csajsp\cdump C:\oracle\admin\csajsp\pfile C:\oracle\admin\csajsp\udump C:\oracle\oradata\csajsp 

The bdump directory holds alert and trace files on behalf of background processes. The cdump directory stores a core dump file should the Oracle server fail and be unrecoverable. The udump directory holds trace files used on behalf of a user process. The oradata\csajsp directory contains the physical database.

Create an Initialization Parameter File

For the database to start up, Oracle must read an initialization parameter file. The parameters in this file initialize many of the memory and process settings of the Oracle instance. The standard naming convention for an initialization parameter file is init SID .ora , where SID is the system identifier for the database.

An instance is a combination of the memory and background processes associated with the database. A significant component of the instance is the System Global Area (SGA) that is allocated when the instance is started. The SGA is a memory area that stores and processes data retrieved from the physical database.

Core Note

graphics/bwopenglobe_icon.gif

An Oracle instance consists of the memory structure and background processes to manage the database. An initialization parameter file is required for starting an instance.


In practice, most database administrators simply copy and modify an existing parameter file when they need to create a new database. Listing 18.1 presents an example initialization parameter file that creates a database named csajsp on Windows XP. Place this file in the C:\oracle\admin\csajsp\pfile directory.

For more information on initialization parameters, see Chapter 1 of the online Oracle9i Database Reference at http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96536/toc.htm. The minimum parameters that must be specified in an initialization parameter file are background_dump_dest , compatible , control_files , db_block_buffers , db_name , shared_pool_size , and user_dump_dest .

Listing 18.1 initCSAJSP.ora (database initialization parameter file)
 # Initialization parameter file for Oracle9i database # on Windows XP. # Database Identification db_domain=coreservlets.com db_name=csajsp # Instance Identification instance_name=csajsp # Cache and I/O db_block_size=8192 db_cache_size=25165824 db_file_multiblock_read_count=16 # Cursors and Library Cache open_cursors=300 # Diagnostics and Statistics background_dump_dest=C:\oracle\admin\csajsp\bdump core_dump_dest=C:\oracle\admin\csajsp\cdump timed_statistics=TRUE user_dump_dest=C:\oracle\admin\csajsp\udump # File Configuration control_files=("C:\oracle\oradata\csajsp\CONTROL01.CTL",                "C:\oracle\oradata\csajsp\CONTROL02.CTL",                "C:\oracle\oradata\csajsp\CONTROL03.CTL") # Job Queues job_queue_processes=10 # MTS dispatchers="(PROTOCOL=TCP) (SERVICE=csajspXDB)" # Miscellaneous aq_tm_processes=1 compatible=9.2.0.0.0 # Optimizer hash_join_enabled=TRUE query_rewrite_enabled=FALSE star_transformation_enabled=FALSE # Pools java_pool_size=33554432 large_pool_size=8388608 shared_pool_size=50331648 # Processes and Sessions processes=150 # Redo Log and Recovery fast_start_mttr_target=300 # Security and Auditing remote_login_passwordfile=EXCLUSIVE # Sort, Hash Joins, Bitmap Indexes pga_aggregate_target=25165824 sort_area_size=524288 # System Managed Undo and Rollback Segments undo_management=AUTO undo_retention=10800 undo_tablespace=undotbs 
Create a Password File

If the initialization parameter REMOTE_LOGIN_PASSWORDFILE is set to EXCLUSIVE , a password file must be created to authenticate administrators that have SYSDBA privileges. Connecting to an Oracle service with SYSDBA privileges gives the administrator unrestricted ability to perform any operation on the database. Using a password file to authenticate the administrator provides the greatest level of security.

Use the ORAPWD command-line tool to create a password file. The command accepts three arguments: FILE , which specifies the location and filename of the password file; PASSWORD , which specifies the password to assign to user SYS for administering the database; and ENTRIES , which specifies the maximum number of users to whom you intend to grant SYSDBA privileges for administering the database (the user SYS already has SYSDBA privileges).

For example, the following command,

 
 Prompt>  ORAPWD FILE="C:\oracle\ora92\DATABASE\PWDcsajsp.ora"   PASSWORD=csajspDBA ENTRIES=5  

creates the password file named PWDcsajsp.ora , with csajspDBA as the SYS user password to administrate the database. The ENTRIES value of 5 defines a total of 5 users (administrators) with SYSDBA privileges in the password file.

By convention, for Oracle9i, the password file is placed in the C:\oracle\ora92\DATABASE directory and the name of the password file is PWD database .ora , where database is the name (SID) of the database associated with the password file.

Create an Oracle Service for the Database

Before creating the database on Windows NT/2000/XP, you need to create an Oracle service to run the database. Creating an Oracle service avoids process termination of the database when the administrator logs out of the computer. To accomplish this step, use the oradim command-line utility.

Assuming that the SID for your database is csajsp and the initialization parameter file is initCSAJSP.ora , located in C:\oracle\admin\csajsp\pfile , use the following command to create the Oracle service.

 
 Prompt>  oradim -NEW -SID CSAJSP -STARTMODE MANUAL   -PFILE "C:\oracle\admin\csajsp\pfile\initCSAJSP.ora"  

This command will create a service named OracleServiceCSAJSP , configured to start up manually. When first created, however, the service should start. To check that the service has started, issue the following command.

 
 Prompt>  net start OracleServiceCSAJSP  

If you want the database service to start when the computer is rebooted, change the service startup type to automatic. To change the startup type on Windows XP, go to the Start menu, then Control Panel, then Performance and Maintenance, then Administrative Tools, Services, then right-click the service to change and select Properties. Next, simply change the Startup type from the available dropdown list.

Declare the ORACLE_SID Value

The ORACLE_SID is an environment variable used by various Oracle tools (e.g., SQL*Plus) to identify which database to operate upon. To set the ORACLE_SID to the csajsp database, enter the following command.

 
 Prompt>  set ORACLE_SID=csajsp  

Note that there should be no spaces around the equal (=) character.

Connect to the Oracle Service as SYSDBA

The next step is to use SQL*Plus to connect to the database service as a system DBA ( SYSDBA ) before creating the new database. First, start SQL*Plus with the nolog option, as below.

 
 Prompt>  SQLPLUS /nolog  

Then, connect to the Oracle service as SYSDBA , using the following command,

 
 SQL>  CONNECT SYS/   password   AS SYSDBA  

where password is the SYS password you specified when creating the password file earlier. Note: by your setting of the ORACLE_SID environment variable, SQL*Plus automatically knows the database service in which to connect ( OracleServiceCSAJSP , in this case).

Start the Oracle Instance

The Oracle instance must be started to create a new database. To start the instance without mounting the database, issue the following command in SQL*Plus.

 
 SQL>  STARTUP NOMOUNT   PFILE="C:\oracle\admin\csajsp\pfile\initCSAJSP.ora"  

The PFILE must refer to the file containing the initialization parameters for the database. Starting the instance in NOMOUNT creates the SGA and starts background processes. However, the database cannot be accessed. Typically, you start a database in NOMOUNT only during creation of the database or during maintenance of the database (e.g., creating control files).

Create the Database

To create a new database, you issue the CREATE DATABASE SQL command in SQL*Plus. Listing 18.2 provides a CREATE DATABASE command to create the csajsp database on a Windows NT/2000/XP platform. To create the database, simply type (cut and paste) this command to SQL*Plus. Or alternatively, you can create the database by running the create_csajsp.sql script from SQL*Plus. To execute the script, use the following command.

 
 SQL>  @create_csajsp.sql  

Note that you may need to specify the full path after the @ for SQL*Plus to find the script.

Execution of this command (or script) creates the csajsp database in the C:\oracle\oradata\csajsp directory and automatically creates two user accounts, SYS and SYSTEM , to administer the database. SYS is the owner of the database dictionary (information about structure and users of the database), and SYSTEM is the owner of additional tables and views used by Oracle tools.

If the database creation fails, examine the alert log file, C:\oracle\admin\csajsp\bdump\alert_csajsp.log , for errors. Correct the problem, delete all the files in the C:\oracle\oradata\csajsp directory, and reissue the command.

Listing 18.2 create_csajsp.sql
 /* SQL command to create an Oracle9i database named csajsp. */ CREATE DATABASE csajsp   USER SYS IDENTIFIED BY csajspDBA   USER SYSTEM IDENTIFIED BY csajspMAN   LOGFILE     GROUP 1 ('C:\oracle\oradata\csajsp\redo01.log') SIZE 100M,     GROUP 2 ('C:\oracle\oradata\csajsp\redo02.log') SIZE 100M,     GROUP 3 ('C:\oracle\oradata\csajsp\redo03.log') SIZE 100M   MAXLOGFILES 5   MAXDATAFILES 100   MAXINSTANCES 1   CHARACTER SET WE8MSWIN1252   NATIONAL CHARACTER SET AL16UTF16   DATAFILE 'C:\oracle\oradata\csajsp\system01.dbf'     SIZE 325M REUSE     AUTOEXTEND ON NEXT 10240K MAXSIZE UNLIMITED     EXTENT MANAGEMENT LOCAL   DEFAULT TEMPORARY TABLESPACE temp     TEMPFILE 'C:\oracle\oradata\csajsp\temptbs01.dbf'     SIZE 20M REUSE     EXTENT MANAGEMENT LOCAL   UNDO TABLESPACE undotbs     DATAFILE 'C:\oracle\oradata\csajsp\undotbs01.dbf'     SIZE 200M REUSE       AUTOEXTEND ON NEXT 5120K MAXSIZE UNLIMITED; 
Create a User Tablespace

Before users can store information in a database, you must create a tablespace for them. All tables created by the user are placed in the tablespace. To create a user tablespace, enter the following command in SQL*Plus.

 
 SQL>  CREATE TABLESPACE users   DATAFILE 'C:\oracle\oradata\csajsp\users01.dbf'   SIZE 15M REUSE   AUTOEXTEND ON NEXT 1280K MAXSIZE UNLIMITED   EXTENT MANAGEMENT LOCAL;  

This command creates a tablespace named users with an initial size of 15 Mbytes. The data is physically stored in the file users01.dbf .

Run Scripts to Build Data Dictionary Views

The last step in creating the database is to run the catalog.sql and catproc.sql scripts from SQL*Plus. Enter the full path to the script preceded by an @ .

 
 SQL>  @C:\oracle\rdbms\admin\catalog.sql  SQL>  @C:\oracle\rdbms\admin\catproc.sql  

The catalog.sql script creates views and synonyms for the data dictionary tables. The catproc.sql script runs all scripts required or used with Oracle PL/SQL. Both of these scripts generate considerable output, which can be ignored; error messages may occur as tables and views are first dropped before being created.

Create a User

To access the database from a Web application, you'll need to create a new user with the appropriate rights. From SQL*Plus, enter the following CREATE USER command,

 
 SQL>  CREATE USER   username   IDENTIFIED BY   password   DEFAULT TABLESPACE users   QUOTA UNLIMITED ON users   TEMPORARY TABLESPACE temp;  

where username is the login name for the new user and password is the password for the new user. The default tablespace is where tables created by the user are placed, and the QUOTA clause grants unlimited use to store information in the users tablespace. If a QUOTA is not specified for the default tablespace, then the user cannot create any tables. A temporary tablespace is also assigned to the user for sorting data if required by the SQL query.

Next, you need to grant the new user rights to connect to the database service and to create new tables. Issue the following SQL*Plus command,

 
 SQL>  GRANT CREATE SESSION, CREATE TABLE   TO   username   ;  

where username is the user requiring access to the database. Granting the CREATE TABLE privilege also enables the user to drop tables.

Install the JDBC Driver

In our JDBC examples, we use the Oracle Thin JDBC driver, which establishes a direct TCP connection to the Oracle database server. Oracle JDBC drivers are downloadable from http://otn.oracle.com/software/tech/java/sqlj_jdbc/. Download the appropriate version, bundled as classes12.zip (for use with JDK 1.2 and JDK 1.3) or ojdbc14.jar (for use with the JDK 1.4) and place it in your CLASSPATH for development and in your application's WEB-INF/lib directory for deployment.

If multiple applications on the Web server access Oracle databases, the Web administrator may choose to move the JAR file to a common directory on the container. For example, with Tomcat, JAR files used by multiple applications can be placed in the install_dir /common/lib directory.

If your Web application server does not recognize ZIP files located in the WEB-INF/lib directory, you can change the extension of the file to .jar ; ZIP and JAR compression algorithms are compatible (JAR files simply include a manifest with metainformation about the archive). However, some developers choose to unzip the file and then create an uncompressed JAR file by using the jar tool with the -0 command option. Both compressed and uncompressed JAR files are supported in a CLASSPATH , but classes from an uncompressed JAR file can load faster. See http://java.sun.com/j2se/1.4.1/docs/tooldocs/tools.html for platform-specific documentation on the Java archive tool.

As a final note, if security is also important in your database transmissions, see http://download-west.oracle.com/docs/cd/B10501_01/java.920/a96654/advanc.htm, for ways to encrypt traffic over your JDBC connections. To encrypt the traffic from the Web server to the client browser, use SSL (for details, see the chapters on Web application security in Volume 2 of this book).



Core Servlets and JavaServer Pages (Vol. 1.Core Technologies)
Core Servlets and Javaserver Pages: Core Technologies, Vol. 1 (2nd Edition)
ISBN: 0130092290
EAN: 2147483647
Year: 2002
Pages: 194

Similar book on Amazon

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