The database server DB2 Express-C, provided by IBM, comes with a database called “SAMPLE”. Let’s use Code On Time web application generator to create a web app straight from this database.
Installing and Configuring DB2
The first step is to download the DB2 Express-C 10.1.2 for Windows 64-bit from the IBM website.
When the download is complete, run the executable. Follow the steps to install DB2 on your computer.
Creating a Web Application
Start the web app generator and click on the Create a new web application link on the start page. On the New Project screen, select Web Site Factory.
![Creating a new Web Site Factory application. Creating a new Web Site Factory application.](/blog/2013/02/db2-sample-web-application/image02.png)
Assign a name of “DB2Sample”, select your preferred programming language, and press Create.
![Creating a new project called 'DB2Sample'. Creating a new project called 'DB2Sample'.](/blog/2013/02/db2-sample-web-application/image04.png)
Preserve the default Namespace and Framework, and press Next.
![Namespace and Framework page of Code On Time project wizard. Namespace and Framework page of Code On Time project wizard.](/blog/2013/02/db2-sample-web-application/image06.png)
From the Data Provider dropdown, select IBM DB2 .NET Data Provider.
![Creating a DB2 database connection string. Creating a DB2 database connection string.](/blog/2013/02/db2-sample-web-application/image08.png)
To the right of the Connection String field, click on the “…” button to activate the Connection String Assistant.
If you are using a locally installed database, use the following configuration:
If you want to connect to a local database as a different user, use Server of “127.0.0.1” or “localhost”. If you are using a remote database, model your configuration after the one below:
Server: | [IP Address]:[Port] |
Database: | SAMPLE |
User name: | [User name] |
Password: | [Password] |
Press Test to confirm that the settings are configured correctly.
![The connection succeeds when tested. The connection succeeds when tested.](/blog/2013/02/db2-sample-web-application/image10.png)
Press OK to insert the connection string into the field.
![Configured connection string inserted into the 'Connection String' field. Configured connection string inserted into the 'Connection String' field.](/blog/2013/02/db2-sample-web-application/image12.png)
Press Next twice to reach the Reporting page. Check the box to enable reporting.
![Enabling reporting for the Web Site Factory web application. Enabling reporting for the Web Site Factory web application.](/blog/2013/02/db2-sample-web-application/image14.png)
The next page allows configuration of Custom Membership and Role Providers. Leave the default settings and press Next until you reach the Theme page. Select “Summer” from the list box.
![Selecting the 'Summer' theme in the Project Wizard. Selecting the 'Summer' theme in the Project Wizard.](/blog/2013/02/db2-sample-web-application/image16.png)
Hold down Shift key and press Next to skip to the Summary page. Press Generate to create the web application.
![The Summary screen of the Project Wizard. The Summary screen of the Project Wizard.](/blog/2013/02/db2-sample-web-application/image18.png)
When generation is complete, the web application will open in the default browser.
![Default Employee page of a generated web application from SAMPLE DB2 database. Default Employee page of a generated web application from SAMPLE DB2 database.](/blog/2013/02/db2-sample-web-application/image20.png)