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.
In the New Example dialog, select Workshop JPA
Examples > Workshop
JPA Tutorial from the list.
Click Next.
Verify that the value workshop-jpa-tutorial is in the
project name field and click Next.
If a license dialog appears, review the license carefully and if you accept the terms, click I Agree.
Click Finish to create the new JPA Web Application
project.
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.
Open the DbXplorer View, if it is not visible. To open
the DbXplorer View, click Window > Show
View > DbXplorer.
Right-click anywhere within the body of the DbXplorer view
and select New
Connection.
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.
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.
In the JDBC Driver Class field, click Browse and
select org.hsqldb.jdbcDriver.
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.
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
.
For User, enter sa.
Click the Test Connection button to verify the connection
information.
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.
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.
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: