+ All Categories
Home > Documents > Using JDBC Data Source with DB2

Using JDBC Data Source with DB2

Date post: 14-Jun-2015
Category:
Upload: tess98
View: 951 times
Download: 0 times
Share this document with a friend
Popular Tags:
12
Using JDBC Data Source with DB2 Elixir Repertoire support connectivity to DB2 via DB2 Universal JDBC driver with Elixir data source. Version tested : Prerequisite Below list the prerequisite that is needed to ensure a successful connection to Microsoft SQL Server. 1) DB2 Universal JDBC Drivers as jars db2jcc.jar, db2jcc_javax.jar, db2jcc_license_cu.jar This can be found in DB2 installation directory in IBM\SQLLIB\java. 2) TCP is set. Default port is 50000 . 3) Ensure that the DB2 services are started 4) Deploy the driver into Elixir Repertoire ext directory. You have to the same if you are using Elixir Repertoire Server.
Transcript
Page 1: Using JDBC Data Source with DB2

Using JDBC Data Source with DB2

Elixir Repertoire support connectivity to DB2 via DB2 Universal JDBC driver with Elixir data source.

Version tested :

PrerequisiteBelow list the prerequisite that is needed to ensure a successful connection to Microsoft SQL Server.

1) DB2 Universal JDBC Drivers as jars

db2jcc.jar, db2jcc_javax.jar, db2jcc_license_cu.jar

This can be found in DB2 installation directory in IBM\SQLLIB\java.

2) TCP is set. Default port is 50000 .

3) Ensure that the DB2 services are started

4) Deploy the driver into Elixir Repertoire ext directory. You have to the same if you are using Elixir Repertoire Server.

Page 2: Using JDBC Data Source with DB2

5) You can view the tables in DB2 Control Panel

Page 3: Using JDBC Data Source with DB2

Creating a JDBC Data Source in Elixir Repertoire

These are the following step to create JDBC Data Source in Elixir Repertoire.

1) Obtain the JDBC connection parameters

They are the Database server database location, database name , port (50000 default), user name and password.

Here is the different show in the table.

Server DB2 Server version 9.1JDBC Driver com.ibm.db2.jcc.DB2DriverURL jdbc:db2:// example jdbc:db2://<host>:50000/dbname

Page 4: Using JDBC Data Source with DB2

2) Step to the next page to obtain the SQL Statement with Query Builder or enter a SQL statement to select the table i.e.

SELECT * FROM ADMINISTRATOR.DEPARTMENT

3) Infer the schema

Page 5: Using JDBC Data Source with DB2

4) Finally you test the result of the SQL Statement in the Data->Load Data.

Page 6: Using JDBC Data Source with DB2

Using DB2 Store Procedure

Creating Store procedure in DB2.

1) Stored procedures are created in the Development Center, provided by IBM

2) You can use the wizard provide to create a select statement and test the procedures using the Development Center.

Page 7: Using JDBC Data Source with DB2

3) The Store procedure create as

CREATE PROCEDURE PROCEDURE_EMPLOYEE_BY_DEPARTMENT (IN dept varchar(100) )DYNAMIC RESULT SETS 1

-------------------------------------------------------------------------- SQL Stored Procedure ------------------------------------------------------------------------P1: BEGIN

-- Declare cursorDECLARE cursor1 CURSOR WITH RETURN FOR

SELECT EMPNO, FIRSTNME, MIDINIT, LASTNAME, WORKDEPT, PHONENO, HIREDATE, JOB, EDLEVEL, SEX, BIRTHDATE, SALARY, BONUS, COMM FROM ADMINISTRATOR.EMP WHERE WORKDEPT LIKE dept;

-- Cursor left open for client applicationOPEN cursor1;

END P1

The in parameters is the varchar value for department number.

4)At the JDBC SQL entry wizard page, enters the store procedure as

where call procedure-name[([parameter][,[parameter]]...)].

as with the above procedures

call DB2ADMIN.PROCEDURE_EMPLOYEE_BY_DEPARTMENT('A001')

Page 8: Using JDBC Data Source with DB2

5) You can insert Dynamic parameter for UI as

${LabelName# Field type #default value }.

The field type used is lookup where the the first parameter is the data source and second parameter is the field name. Where lookup is a special key to trigger a lookup to a data source and extract the value based on the field name to populate a combo box.

The below is the an example

${DEPT#lookup(/ElixirSamples/DataSource/JDBC/DB2-V9/DEPT.ds,DEPTNO)

This is the actual SQL.

call DB2ADMIN.PROCEDURE_EMPLOYEE_BY_DEPARTMENT('${DEPT#lookup(/ElixirSamples/DataSource/JDBC/DB2-V9/DEPT.ds,DEPTNO)#%}

')

6) Trigger the data source, the Dynamic entry combo box is generated

Page 9: Using JDBC Data Source with DB2

7) The valued displayed.

Page 10: Using JDBC Data Source with DB2

Using Elixir Report to view image stored as Blob database type

1) Step through the similar JDBC data source

2) Enter the SQL query

SELECT * FROM ADMINISTRATOR.EMP_PHOTO3) Infer the schema

Image which store as blob will be recognized as a SQL Blob type in Elixir Repertoire data source.

Page 11: Using JDBC Data Source with DB2

4) Create a report to view the image

Page 12: Using JDBC Data Source with DB2

Report generated


Recommended