How to connect RFT script to iSeries DB2
Published by عادل on Thursday, July 02, 2009 at 5:09 PM
1.Install the iSeries Navigator with its DB components. Your Admin can do that.
2.In windows, go to Control Panel->Administrative Tools->Data Source (ODBC)

3.Click Add
4.Select iSeries Access ODBC Driver. Then click Finish.

5.In the General Tab, in Data Source Name field type an arbitrary DB Name of your choice

6.In the Server tab change the SQL Default Library to DB library name

7.In the Packages Tab change the Package Library to DB library name then press ok.

8.Now you’re ready to connect RFT scripts to
9.From within your RFT script, you need to establish a connection between RFT and system DB. The following example code will show you how to do that:
//establish a connection try{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");} catch(ClassNotFoundException c){ logError(c.getLocalizedMessage());} //sample query try{ Connection db_connection = DriverManager.getConnection("jdbc:odbc:DB_NAME","username","password"); Statement stm2 = db_connection.createStatement(); stm2.executeQuery("select * from table1");} catch( SQLException x ){ logError(x.getLocalizedMessage().toString());}
10. It’s recommended that you parameterize the database name, username and password by prompting the user in the begging of the script. This will save you the headache of refactoring the script when those credentials change.
11. Sometimes your script needs to do insert statements. You need to make sure that the authenticated user is having the enough privilege. Otherwise your script will crash.


