Step 1. Setup Web Project and Connect to Database

Time to complete this step: 15 minutes

In this step, you will create a new web applcation project and connect to a database.

The tasks in this step are:

Configure WebLogic Server

In this step you will add a WebLogic Server domain for use with Workshop. This server domain contains runtime libraries required by the application and the application will be deployed to this server.

Note that this tutorial requires WebLogic Server version 10.0.


Create a New Web Project

  1. Choose File > New > Example .
  2. In the New Example dialog, select JPA > Workshop JPA Tutorial from the list.
  3. Click Next.
  4. Verify that the value workshop-jpa-tutorial is in the project name field and click Next.


  5. If a license dialog appears, click I Agree.
  6. Review the Java build settings. By default, workshop-jpa-tutorial/web/WEB-INF/src/java is selected as the source folder and workshop-jpa-tutorial/web/WEB-INF/classes as the output folder.

    Click Finish to create the new project.


    alt

To Create a New Database Connection

In this step, we will learn how to explore databases using the DbXplorer™. Workshop allows you to connect to any database, analyze database schemas, tables, columns, and populate the database with sample data.

The DbXplorer provides an intuitive interface for database access through Workshop. It allows you to setup the database connection, review the database artifacts, query the data in an existing table or column, and generate object relational mappings.

  1. Select the DbXplorer view
  2. Right-click anywhere within the body of the DbXplorer view and select New Connection.

  3. In the Add Database Connection wizard, enter a database connection name. The database connection name can be arbitrary and does not need to match the actual name of the database server. For this tutorial, use the name SalesDBConnection.

  4. In the Add Database Connection dialog, click Add and browse to the Hypersonic JDBC driver file, <path to workspace>\workshop-jpa-tutorial\web\WEB-INF\lib\hsqldb.jar.

    Click Next.

  5. Workshop provides sample Database URL's for some standard databases, which can be accessed from the Populate from database defaults pull down menu. Select HypersonicSQL In-Memory.

  6. In the Database URL field, replace the curly brackets {db filename} with the location of the Hypersonic database script file, using the following syntax: <absolute path to workspace>\workshop-jpa-tutorial\web\hsqlDB\SalesDB.
  7. In the User field, enter sa.
  8. Click the Test Connection button to verify the connection information.

  9. In the Information dialog, click OK.

  10. In the Add Database Connection dialog, click Finish.

    The new database connection should now appear in the DbXplorer view.


Browse Database Artifacts using DbXplorer (Optional)

In this step, you will use the DbXplorer view to browse database artifacts.

  1. In the DbXplorer view, expand the nodes inside the SalesDBConnection node. You can view the individual tables and columns. Observe that the DbXplorer view denotes which columns have been designated as primary keys.

  2. While browsing database artifacts, the Properties view displays the relevant properties of the component.



 

Click one of the following arrows to navigate through the tutorial:


Still need help? Post a question on the Workshop newsgroup.