WASdev/sample.servlet.jdbc

Name: sample.servlet.jdbc

Owner: WASdev

Description: Basic servlet sample with a simple JDBC datasource definition. #JavaEE7

Created: 2017-02-03 15:11:51.0

Updated: 2017-02-03 15:19:01.0

Pushed: 2017-10-24 21:16:57.0

Homepage: null

Size: 72

Language: Java

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

JDBC Servlet Sample Build Status

The ServletJDBCEngine sample contains a server definition for basic servlet support, and illustrates a simple datasource definition using an included configuration file. It uses Apache Derby (an open source relational database). Also included is a servlet which gets a connection to the database using the defined datasource, creates a table, inserts some data, retrieves the data, and prints the data out to the browser.

Once the server is running, the application will be available under http://localhost:9080/JDBCApp.

Running with Maven
Running in Eclipse with Maven
  1. Clone this project and import into Eclipse as an 'Existing Maven Project'.
  2. Right-click the project and select Run As > Maven Clean.
  3. Right-click the project and select Run As > Maven Install.
  4. Right-click the project and select Run As -> Run on Server.
  5. You should see the following in the console: CWWKZ0001I: Application JDBCApp started in XX.XX seconds. In your browser, enter the URL for the application: http://localhost:9080/JDBCApp. In your browser, you should see the message: Text retrieved from database is: myHomeCounty
Running from the command-line with Maven

This project can be built with Apache Maven. The project uses the Liberty Maven Plug-in to automatically download and install the Liberty Java EE Web Profile 7 from Maven Central. The Liberty Maven Plug-in is also used to create, configure, and run the application on the Liberty server.

Use the following steps to run the application with Maven:

  1. Execute full Maven build. The Liberty Maven Plug-in will download and install the Liberty server.

    n clean install
    
  2. To run the server with the Servlet sample execute:

    n liberty:run-server
    
Running with Gradle

This project can also be built and run using Gradle. The provided build.gradle file applies the Liberty Gradle Plug-in and is configured to automatically download and install the Liberty Java EE Web Profile 7 runtime from Maven Central. The Liberty Gradle Plug-in also has tasks that create, configure, and run applications on a Liberty server.

Use the following steps to run the application with the Gradle wrapper. (Windows machines use gradlew.bat):

  1. Execute the full Gradle build. The Liberty Gradle Plug-in will download and install the Liberty server.

    gradlew clean build
    
  2. To start the server with the JDBCApp sample run:

    gradlew libertyStart
    

    Alternatively, execute the run command:

    gradlew libertyRun --no-daemon
    
  3. To stop the server, execute:

    gradlew libertyStop
    

Please refer to the Liberty Gradle Plug-in repository for documentation and configuration examples for the plug-in.

Notice

© Copyright IBM Corporation 2017.

License

nsed under the Apache License, Version 2.0 (the "License");
may not use this file except in compliance with the License.
may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

ss required by applicable law or agreed to in writing, software
ributed under the License is distributed on an "AS IS" BASIS,
OUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
the License for the specific language governing permissions and
tations under the License.

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.