2011NOV18+XPages+Goes+Relational

26
7/30/2019 2011NOV18+XPages+Goes+Relational http://slidepdf.com/reader/full/2011nov18xpagesgoesrelational 1/26  ©2011 IBM Corporation Webinar: XPages Goes Relational! November 18th, 2011  Andrejus Chaliapinas Senior Software Developer | XPages, IBM Ireland =

Transcript of 2011NOV18+XPages+Goes+Relational

Page 1: 2011NOV18+XPages+Goes+Relational

7/30/2019 2011NOV18+XPages+Goes+Relational

http://slidepdf.com/reader/full/2011nov18xpagesgoesrelational 1/26

 

©2011 IBM Corporation

Webinar: XPages Goes Relational!November 18th, 2011

 Andrejus ChaliapinasSenior Software Developer | XPages, IBM Ireland

● =

Page 2: 2011NOV18+XPages+Goes+Relational

7/30/2019 2011NOV18+XPages+Goes+Relational

http://slidepdf.com/reader/full/2011nov18xpagesgoesrelational 2/26

© 2011 IBM Corporation  2

 Agenda

● XPages Extension Library OpenNTF 8.5.3 and IBM position in regardsto official support

● Installation steps on server/client

● Demo of installation steps

Stage of XPages Relational support implementation● New data sources for RDBMS connectivity

●  Additionally required manual connection configuration step

● @Functions available for Server Side Javascript

● Demo using DB2 Express instance● Q&A

Page 3: 2011NOV18+XPages+Goes+Relational

7/30/2019 2011NOV18+XPages+Goes+Relational

http://slidepdf.com/reader/full/2011nov18xpagesgoesrelational 3/26

© 2011 IBM Corporation  3

XPages Extension Library OpenNTF 8.5.3 andIBM position in regards to official support

● Currently could be found at http://extlib.openntf.org/ where all latest demos are posted and discussion threads are available

● Download from Downloads/Releases section

Page 4: 2011NOV18+XPages+Goes+Relational

7/30/2019 2011NOV18+XPages+Goes+Relational

http://slidepdf.com/reader/full/2011nov18xpagesgoesrelational 4/26

© 2011 IBM Corporation  4

XPages Extension Library OpenNTF 8.5.3 andIBM position in regards to official support (cont.)

● Notes/Domino 8.5.3 targeting version was initially released on October 17th, 2011.

●  As of November 18th latest release is provided via file named:ExtensionLibraryOpenNTF-853.20111027-1245a.zip

● From News section you should read this important post:

XPages Extension Library - News: October 20th Release - Notes from Peter Janzen where you'll find such statement about this release: 

- “It sets the stage for many of the controls and objects to become asupported set of features for Lotus Notes and Domino.” That means thatwhile this project will continue its existence as an OpenNTF project – partof it with the same code base will be officially supported by IBM.

● There are now 2 sets of plugins included in OpenNTF delivery -“extlib” and “extlibx”. The one called “extlibx” contains now someexperimental code (like XPages Relational) and will be added toofficial support when it will be mature enough for that.

Page 5: 2011NOV18+XPages+Goes+Relational

7/30/2019 2011NOV18+XPages+Goes+Relational

http://slidepdf.com/reader/full/2011nov18xpagesgoesrelational 5/26

© 2011 IBM Corporation  5

Installation steps on server (template to use)

● XPages Extension Library delivery ZIP file contains 2 Eclipse basedupdate sites:

- updateSiteOpenNTF.zip (to be installed on Domino server)

- updateSiteOpenNTF-designer.zip (to be installed in Domino Designer)

● Installation on server side should be done using XPages Extension 

Library Deployment in Domino 8.5.3 and IBM XWork Server technique described in Lotus Notes and Domino Application Development wiki:

- Involves creation of a new NSF application based on updatesite.ntf  template and import of updateSiteOpenNTF.zip into it

- Requires specification of OSGI_HTTP_DYNAMIC_BUNDLES variable

inside your server's notes.ini file to point to update site NSFs- Uses additional safeguards when loading plugins (ACL)

Page 6: 2011NOV18+XPages+Goes+Relational

7/30/2019 2011NOV18+XPages+Goes+Relational

http://slidepdf.com/reader/full/2011nov18xpagesgoesrelational 6/26

© 2011 IBM Corporation  6

Installation steps on server (verification)

● For Domino server to pick up those new artifacts you need to restartyour Domino server issuing console command restart task http

● To verify that the library is properly installed - you should use suchOSGI command on server console:tell http osgi ss com.ibm.xsp.extlib

Page 7: 2011NOV18+XPages+Goes+Relational

7/30/2019 2011NOV18+XPages+Goes+Relational

http://slidepdf.com/reader/full/2011nov18xpagesgoesrelational 7/26

© 2011 IBM Corporation  7

Installation steps on server (additional plugins)

For connection to DB2, MS SQL, mySQL, Oracle and other databasesyou may need to prepare your own plugin, which will wrap specificdatabase JDBC driver (usually available as 1 or 2 vendor's jar files)and then deploy it either to Domino server or Designer client or both

● Currently sample DB2, MS SQL, mySQL (Oracle to follow soon) plugins/update sites with source code are provided on OpenNTF website

● For the purpose of this webinar we'll use freely available DB2 Express-C v9.7.4 RDBMS

● We'll use also Sample DB2 driver update site available asExtlib_8.5.3_DB2_Driver_updateSite201110201044.zip. This update site wraps DB2 JDBC driver, available for download from IBM site

● Verification: tell http osgi ss extlib.driver.db2

Page 8: 2011NOV18+XPages+Goes+Relational

7/30/2019 2011NOV18+XPages+Goes+Relational

http://slidepdf.com/reader/full/2011nov18xpagesgoesrelational 8/26

© 2011 IBM Corporation  8

Installation steps on server (demo database)

With XPages Extension Library you get also demo application, calledXPagesJDBC.nsf , which demonstrates main functionality currentlyavailable for Relational support. You need to copy it to your server (here we'll have it under <Domino_Data>/demo directory) and signwith some user/server ID. If steps were done correctly till this moment- you'll see:

Page 9: 2011NOV18+XPages+Goes+Relational

7/30/2019 2011NOV18+XPages+Goes+Relational

http://slidepdf.com/reader/full/2011nov18xpagesgoesrelational 9/26

© 2011 IBM Corporation  9

Installation steps on server (things to notice)

 At this moment you cannot open yet XPagesJDBC.nsf demoapplication inside your Domino Designer if you have option Project →Build Automatically switched on (which is default), because we don'thave yet required plugins installed for Domino Designer and you'll geta lot of compilation errors making demo application inaccessible fromyour server 

● With Extension Library delivery ZIP you get only embedded Derbydatabase driver installed for quick testing and demo application isconfigured to use it. We'll change that later using Domino Designer touse DB2 driver instead

Page 10: 2011NOV18+XPages+Goes+Relational

7/30/2019 2011NOV18+XPages+Goes+Relational

http://slidepdf.com/reader/full/2011nov18xpagesgoesrelational 10/26

© 2011 IBM Corporation  10

Installation steps on client (preferences)

Installation for Domino Designer requires Enable Eclipse plug-ininstall preference to be enabled

●  After that next steps are done via File → Application → Install menu

and selection of updateSiteOpenNTF-designer.zip file

Page 11: 2011NOV18+XPages+Goes+Relational

7/30/2019 2011NOV18+XPages+Goes+Relational

http://slidepdf.com/reader/full/2011nov18xpagesgoesrelational 11/26

© 2011 IBM Corporation  11

Installation steps on client (update site)

You add that zip as location to install from:

Page 12: 2011NOV18+XPages+Goes+Relational

7/30/2019 2011NOV18+XPages+Goes+Relational

http://slidepdf.com/reader/full/2011nov18xpagesgoesrelational 12/26

© 2011 IBM Corporation  12

Installation steps on client (features list)

One of the features inside it is directly related to XPages Relationalsupport:

Page 13: 2011NOV18+XPages+Goes+Relational

7/30/2019 2011NOV18+XPages+Goes+Relational

http://slidepdf.com/reader/full/2011nov18xpagesgoesrelational 13/26

© 2011 IBM Corporation  13

Installation steps on client (verification)

To verify installation inside Domino Designer you need to open Help → About IBM Lotus Domino Designer menu, click Plug-in Details button,sort by Plug-in Id and check if you have these:

Page 14: 2011NOV18+XPages+Goes+Relational

7/30/2019 2011NOV18+XPages+Goes+Relational

http://slidepdf.com/reader/full/2011nov18xpagesgoesrelational 14/26

© 2011 IBM Corporation  14

Installation steps on client (usage in apps)

Page 15: 2011NOV18+XPages+Goes+Relational

7/30/2019 2011NOV18+XPages+Goes+Relational

http://slidepdf.com/reader/full/2011nov18xpagesgoesrelational 15/26

© 2011 IBM Corporation  15

Installation steps on server/client live demo

Live demo for about 15-20 minutes

Page 16: 2011NOV18+XPages+Goes+Relational

7/30/2019 2011NOV18+XPages+Goes+Relational

http://slidepdf.com/reader/full/2011nov18xpagesgoesrelational 16/26

© 2011 IBM Corporation  16

Stage of XPages Relational supportimplementation

Leverages JDBC to connect to the relational databases-  Accesses any database with a JDBC driver available

- The data is accessed directly: no synchronization needed with NSF

● Connections currently could be defined only within NSF

-

 A NSF contains a new file design element (with .jdbc extension) for defining database specific connections. Such design element editingrequires switch to Navigator view currently and is located inWebContent/WEB-INF/jdbc directory.

● Global connections definition on server will be addressed later 

● Uses a connection pool to optimize the use of connections

- Simple connection pool provided, plan to add support of Apache DBCP

Page 17: 2011NOV18+XPages+Goes+Relational

7/30/2019 2011NOV18+XPages+Goes+Relational

http://slidepdf.com/reader/full/2011nov18xpagesgoesrelational 17/26

© 2011 IBM Corporation  17

New data sources for RDBMS connectivity

There are 2 new data sources you could easily make to be used byyour xp:viewPanel control:

- JDBC Query data source, which provides Read Only access for RDBMS

- JDBC RowSet data source (uses the standard CachedRowSetImpl),which allows you to edit (create/update/delete) RDBMS data

●  Access to different RDBMS table's fields is made through used for Domino views xp:viewColumn controls thus making such usagetransparent for developer by hiding all details

●  At this moment Domino Designer tooling for table definition retrievalfor easier column/field selection is under development and you mayneed to know ahead your table DDL to specify properly columnNameattribute of xp:viewColumn control

Page 18: 2011NOV18+XPages+Goes+Relational

7/30/2019 2011NOV18+XPages+Goes+Relational

http://slidepdf.com/reader/full/2011nov18xpagesgoesrelational 18/26

© 2011 IBM Corporation  18

New data sources for RDBMS connectivity(choices)

This screenshot below demonstrates how you could select those 2new data sources using Properties area (in this case for xp:viewPanelcontrol):

Page 19: 2011NOV18+XPages+Goes+Relational

7/30/2019 2011NOV18+XPages+Goes+Relational

http://slidepdf.com/reader/full/2011nov18xpagesgoesrelational 19/26

© 2011 IBM Corporation  19

New data sources for RDBMS connectivity(SQL queries)

The SQL query can be provided using either -  A table name – The runtime will generate a select * from <table name>

-  A SQL query, from a data source property (static or computed)

-  A SQL file resource (*.sql) containing the SQL statement

● The size of the result set can be computed so the pager can display theactual number of pages

- Enabled using the calculateCount property, which is false by default

- Generates a hidden select count(*) to get the exact size

• Just replaces the select part of the original query by count(*)

•  A specific count query can be provided for performance reasons (ex: avoidordering...)

Page 20: 2011NOV18+XPages+Goes+Relational

7/30/2019 2011NOV18+XPages+Goes+Relational

http://slidepdf.com/reader/full/2011nov18xpagesgoesrelational 20/26

© 2011 IBM Corporation  20

New data sources for RDBMS connectivity(parameterizing)

 A data source can either point to a named connection or a JDBC URL- Named connections are heavily advised as they take advantage of a connection

pool, and they are easier to manage as they are centrally defined

• The JNDI prefix can be omitted in the name

- JDBC URL are for debugging purposes only

● The SQL statement can either be defined (or computed) from a data sourceproperty, or defined in a separate file design element (*.sql)

● Parameters, matching the '?' in the SQL query, are also defined at the datasource level. The order of the parameters must match the order of '?' in the

SQL query

sqlTable: a simple table namesqlQuery: a general sql querysqlFile: points to a .sql design element

Page 21: 2011NOV18+XPages+Goes+Relational

7/30/2019 2011NOV18+XPages+Goes+Relational

http://slidepdf.com/reader/full/2011nov18xpagesgoesrelational 21/26

© 2011 IBM Corporation  21

New data sources for RDBMS connectivity(CRUD)

In XPagesJDBC.nsf demo application you'll find sample of CRUDprovided (XPage called JDBC_RowSetDatasource.xsp) throughwhich you could create/update/delete records in external RDBMS

Page 22: 2011NOV18+XPages+Goes+Relational

7/30/2019 2011NOV18+XPages+Goes+Relational

http://slidepdf.com/reader/full/2011nov18xpagesgoesrelational 22/26

© 2011 IBM Corporation  22

 Additionally required manual connectionconfiguration step (for DB2 here)

To configure your DB2 connection you need to create new designelement (let's call it db2demo.jdbc) and specify in it JDBC driver classto be used, database name and user's credentials:

<jdbc><driver>com.ibm.db2.jcc.DB2Driver</driver><url>jdbc:db2://testvm:50000/DEMO</url><user>demo</user>

<password>test123</password></jdbc>

● Important: part of name before “.jdbc” of such design element, whichis in this case “db2demo” will be used for JDBC data sourcesconfiguration

Reminder: db2demo.jdbc design element should be saved into your application's WebContent/WEB-INF/jdbc folder 

Page 23: 2011NOV18+XPages+Goes+Relational

7/30/2019 2011NOV18+XPages+Goes+Relational

http://slidepdf.com/reader/full/2011nov18xpagesgoesrelational 23/26

© 2011 IBM Corporation  23

@Functions available for Server Side JavaScript

Currently these @Functions are implemented:- @JdbcInsert (sample provided in JDBC_AtFunctions.xsp)

var v = {

id: id,firstName: "Albert",lastName: "Einstein",city: "Boston",state: "MA"

}var c = @JdbcInsert("db2demo","users",v)

- @JdbcUpdate (sample provided in JDBC_AtFunctions.xsp)var v = {

city: "Boston",state: "MA"

}var c = @JdbcUpdate("db2demo","users",v,"id=?",id)

-@JdbcDelete (sample provided in JDBC_AtFunctions.xsp)

var c = @JdbcDelete("db2demo","users","id=?",id)

Page 24: 2011NOV18+XPages+Goes+Relational

7/30/2019 2011NOV18+XPages+Goes+Relational

http://slidepdf.com/reader/full/2011nov18xpagesgoesrelational 24/26

© 2011 IBM Corporation  24

@Functions available for Server Side JavaScript(continued)

-

@JdbcExecuteQuery (sample provided in JDBC_TableMetaData.xsp)var sql = "select * from "+tb;

var rs = @JdbcExecuteQuery('db2demo',sql);

- @JdbcDbColumn (sample provided in JDBC_StaticViewPanelParam.xsp)@JdbcDbColumn("db2demo","states","state")

- @JdbcGetConnection

Page 25: 2011NOV18+XPages+Goes+Relational

7/30/2019 2011NOV18+XPages+Goes+Relational

http://slidepdf.com/reader/full/2011nov18xpagesgoesrelational 25/26

© 2011 IBM Corporation  25

Demo of JDBC data sources using DB2 Expressinstance

Live demo for about 15-20 minutes● For XPagesJDBC.nsf to setup test data inside your DB2 instance you

would need these changes:

- Uncomment these lines inside xpages.DataInitializer Java class:// case GENERIC: {// createTables_Derby();

// } break;

- Specify your connection name inside xpages.DBUtil Java class:this.connectionName = "db2demo";

- Specify the database schema:public String getSchema() {

return "DEMO";

}

Page 26: 2011NOV18+XPages+Goes+Relational

7/30/2019 2011NOV18+XPages+Goes+Relational

http://slidepdf.com/reader/full/2011nov18xpagesgoesrelational 26/26

© 2011 IBM Corporation  26

Q & A