1:import java.sql.*;
 2:import atg.rview.*;
 3:import java.io.*;
 4:
 5:public class Test {
 6:
 7:    static public void main( String[] args ){
 8:        //try running the Relational View for Customers
 9:        Test t = new Test();
10:    }
11:
12:    public Test() {
13:        try{
14:            RelationalViewManager m = createManager( "c:\\data\\Emp\\Employee.rvw" );
15:            RelationalView rv = m.getRelationalView( "DepartmentRview" );
16:
17:            /*
18:            //An example of how to insert a new department
19:            Department d = new Department();
20:            d.setId(5);
21:            d.setName( "Marketing" );
22:
23:            rv.insert( d );
24:            m.commit();
25:            */
26:
27:            //get the list of all Departments
28:            Department[] departments = (Department[])rv.select();
29:            Employee[] employees;
30:            Department d;
31:            //Loop through the departments
32:            for (int i=0;i<departments.length;i++){
33:                //get a handle to the current department
34:                d = departments[i];
35:                System.out.println(d.getName());
36:                //get the employees in the department
37:                employees = (Employee[])d.getEmployees().select();
38:                //loop through the employees and print out their names
39:                for (int j=0;j<employees.length;j++ ){
40:                    System.out.println( "    " + employees[j].getFirstName() );
41:                }
42:            }
43:
44:
45:        } catch (Exception exc){
46:            exc.printStackTrace();
47:        }
48:    }
49:
50:    RelationalViewManager createManager (String descriptionFileName)
51:       throws SQLException, RelationalViewException, ClassNotFoundException {
52:        // Create the relational view manager
53:        RelationalViewManagerImpl manager = new RelationalViewManagerImpl ();
54:        manager.setJoinStyle ("ansi");
55:
56:        // Initialize the manager with the definition file
57:        File [] descriptionFiles = { new File (descriptionFileName) };
58:        manager.initialize (descriptionFiles);
59:
60:        // Create the JDBC connection
61:        Class.forName ("solid.jdbc.SolidDriver");
62:        Connection conn = DriverManager.getConnection ("jdbc:solid://localhost:1313", "admin", "admin");
63:        conn.setAutoCommit (false);
64:        manager.setJDBCConnection (conn);
65:
66:        return manager;
67:    }
68:}
1