|
WebLogic Server 7.0 Code Examples, BEA Systems, Inc. | |||||
See:
Description
| Interface Summary | |
| Extensions | |
| ExtensionsHome | |
| Class Summary | |
| AddressBO | This class represents an address. |
| ArraysClient | This client is the starting point to demonstrate Oracle ARRAY. |
| ArraysDAO | This simple example shows how to use Oracle ARRAYs. |
| BaseClient | Common client functions. |
| BaseDAO | This class provides common database methods. |
| EmployeeBO | This class represents an employee. |
| ExtensionsBean | This class contains logic for the extension ejb. |
| RefsClient | This client is the starting point to demonstrate Oracle REF. |
| RefsDAO | This simple example shows how to use Oracle REFs. |
| StructsClient | This client is the starting point to demonstrate Oracle STRUCT. |
| StructsDAO | This simple example shows how to use Oracle STRUCTs. |
This example demonstrates the usage of SQL3 datatypes in server-side applications with an Oracle database. The sample applications use the supported Oracle extension methods for STRUCTs, REFs, and ARRAYs. To run this example, you must use a connection pool and the Oracle Thin driver.
Note: You can use STRUCTs, REFs, and ARRAYs in server-side applications only.
| Additional Resources for examples.jdbc.oracle.extensions | |
| build.xml | The Java Ant build script, which assembles and deploys required EJBs and client applications for this example. It also includes targets for preparing your database and running the example. |
| table.ddl | SQL code used by the Java Ant db_setup_oracle script to create tables and objects in your database. |
This example uses three client applications to demonstrate retrieving and inserting STRUCTs, and retrieving REFs and ARRAYs:
You compile this example with a single script and then run each client individually. Before you run the example, read through the source code files to get familiar with what actually happens in the example.
To facilitate this example, you create a connection pool and datasource to connect to your Oracle database. You also create the following object types and tables in your database via an ant script:
The following sections describe how to build and run the example.
Before you run this example, you need:
set CLASSPATH=c:\bea;%WL_HOME%\server\lib\classes12.zip;%CLASSPATH%
set PATH=%WL_HOME%\server\bin\oci817_8;%PATH%
ant
When you run the ant script to build the example, it builds all three clients in the example.
The Ant db_setup_oracle script uses these properties when creating tables and objects in your database.
Note: You must have a matching entry for the database in tnsnames.ora.
See Setting Up Examples to Run with an Oracle DBMS for more details.
ant db_setup_oracle
The script creates the required object types and tables in your database.
For more information about setting up your database, see Setting Up Examples to Run with an Oracle DBMS.
set CLASSPATH=c:\bea;%WL_HOME%\server\lib\classes12.zip;%CLASSPATH%
set PATH=%WL_HOME%\server\bin\oci817_8;%PATH%
ant run_structs
ant run_refs
ant run_arrays
When you run the STRUCTs client, you should see the following output in the command shell:
Buildfile: build.xml
run_structs:
[java] Getting employees from database...
[java] Employee#: 100
[java] Name: Alfred Chuang
[java] Address: 1234 Post St
[java] San Francisco, CA
[java]
[java] Employee#: 101
[java] Name: Joe Walker
[java] Address: 3321 Grand Ave
[java] San Diego, CA
[java]
[java] Employee#: 102
[java] Name: Tina Potter
[java] Address: 7111 Ocala St
[java] Tallahassee, FL
[java]
[java] Employee#: 103
[java] Name: Fred Couples
[java] Address: 9201 Park St
[java] Alexandria, VA
[java]
[java]
[java] Inserting employee to database...
[java]
[java] Getting employees from database...
[java] Employee#: 100
[java] Name: Alfred Chuang
[java] Address: 1234 Post St
[java] San Francisco, CA
[java]
[java] Employee#: 101
[java] Name: Joe Walker
[java] Address: 3321 Grand Ave
[java] San Diego, CA
[java]
[java] Employee#: 102
[java] Name: Tina Potter
[java] Address: 7111 Ocala St
[java] Tallahassee, FL
[java]
[java] Employee#: 103
[java] Name: Fred Couples
[java] Address: 9201 Park St
[java] Alexandria, VA
[java]
[java] Employee#: 105
[java] Name: David David
[java] Address: 4431 Canal Street
[java] New Orleans, LA
[java]
BUILD SUCCESSFUL
If you check the command shell running the server, you should see the following:
StructsDAO.getEmployees() -- Number of rows selected: 4 BaseDAO.getNextId() -- Next employees_seq id is 105 StructsDAO.insertEmployee() -- Number of rows inserted: 1 StructsDAO.getEmployees() -- Number of rows selected: 5
When you run the REFs client, you should see the following output in the command shell:
Buildfile: build.xml
run_refs:
[java] Getting refs from database...
[java]
[java] See server output for results.
BUILD SUCCESSFUL
Check the command shell running the server to see the following:
RefsDAO.getAddresses() -- Id = 1001, Name = Alfred Chuang, Address Id = 100, Street = 1234 Post St, City = San Francisco, State = CA RefsDAO.getAddresses() -- Id = 1002, Name = Joe Walker, Address Id = 101, Street = 3321 Grand Ave, City = San Diego, State = CA RefsDAO.getAddresses() -- Id = 1003, Name = Fred Couples, Address Id = 102, Street = 9201 Park St, City = Alexandria, State = VA
When you run the ARRAYs client, you should see the following output in the command shell:
Buildfile: build.xml
run_arrays:
[java] Getting arrays from database...
[java]
[java] See server output for results.
BUILD SUCCESSFUL
Check the command shell running the server to see the following:
ArraysDAO.getStudents() -- Id = 100, Student = Trey Anastasio Test1 = 100 Test2 = 87 Test3 = 90 Test4 = 89 Test5 = 99 ArraysDAO.getStudents() -- Id = 101, Student = Mike Gordon Test1 = 89 Test2 = 76 Test3 = 100 Test4 = 80 Test5 = 85 ArraysDAO.getStudents() -- Id = 102, Student = Page McConnell Test1 = 100 Test2 = 100 Test3 = 95 Test4 = 98 Test5 = 75 ArraysDAO.getStudents() -- Id = 103, Student = Jon Fishman Test1 = 55 Test2 = 70 Test3 = 76 Test4 = 60 Test5 = 75
|
Documentation is available at http://e-docs.bea.com/wls/docs70 |
|||||