Previous Next vertical dots separating previous/next from contents/index/pdf

Step 1. Setup Web Project and Connect to Database

Time to complete this step: 15 minutes

A Web Project is an Eclipse Java project that contains the source code, web pages, images, resources, and configuration files for building a web application. In this step, you will create a new web project and connect to a database.

Undeploy Previous Tutorial Code

WebLogic Server does not support the deployment of projects with the same name from two different locations on disk.

For this reason, anytime you deploy a sample or run through a tutorial, you should check your server for previous deployments of the same code. If your server already has a deployment of the sample or tutorial code, you should undeploy any previous code.

The tasks in this step are:

To Create a New Web Project

  1. Choose File > New > Example .
  2. In the New Example dialog, select Workshop JPA Examples > 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, review the license carefully and if you accept the terms, click I Agree.

  6. Click Finish to create the new JPA Web Application project.
  7. 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.

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 to setup the database connection, review the database artifacts, query the data in an existing table or column, and generate object relational mappings.

  1. Open the DbXplorer View, if it is not visible. To open the DbXplorer View, click Window > Show View > DbXplorer.
  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. In the JDBC Driver Class field, click Browse and select org.hsqldb.jdbcDriver.
  6. 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.

  7. For database URL jdbc:hsqldb:{db filename}, specify the Hypersonic database script file location for {db filename} as <path to workspace>\workshop-jpa-tutorial\web\hsqlDB\SalesDB .
  8. For User, enter sa.

  9. Click the Test Connection button to verify the connection information.

  10. Click Finish. The new database connection should now appear in DbXplorer.


To Browse Database Artifacts using DbXplorer

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.

 

Skip navigation bar   Back to Top