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
This sample can be installed onto runtime versions 18.104.22.168 and later.
Online installation (requires 22.214.171.124 or later):
installUtility install JDBCSample
Any missing features required by the server will be installed for you.
JDBCSample.jarusing the download button at the top of the page and place it in the root of your server installation.
java -jar JDBCSample.jar
Any missing features required by the server will need to be installed separately.
To run the JDBCApp application:
bindirectory in the Liberty profile installation:
server run JDBCSample
CWWKZ0001I: Application JDBCApp started in XX.XX seconds.
Text retrieved from database is: myHomeCounty
JDBCApp.war file contains the source and binaries for the application, and can be used to import it to Eclipse.
The created database is stored in usr/shared/resources/data/exampleDB as specified by the 'databaseName' property of the datasource.
This sample does not include the open source dependencies. The installer will provide a list of the open source pre-requisite libraries and where they can be downloaded from. To help obtaining these libraries, the installer provides the option to download them on your behalf.