Enhydra and IMAGE/SQL via JDBC
Using the Lutris Enhydra Application Server
to access data in IMAGE/SQL databases
on MPE/iX systems via JDBC

 

v2.0 – August 2001


presented by Jon Diercks
Systems Administrator
ORBiT Group International
165 N Redwood Dr Ste 200
San Rafael, CA 94903
http://diercks.net/jon/papers/
jon_diercks@orbitsw.com - 800-896-7248

What attendees will learn:

·        How to obtain and install Enhydra and JDBC.

·        How to develop a simple Enhyrda application

·        How to connect a simple Enhydra app to an IMAGE/SQL database using JDBC.

Abstract:

The Enhyrda Application Server from Lutris was one of the most talked-about technologies at HPWorld 2000. This open-source java-servlet framework offers lots of power for developing well-structured high-performance web applications. This tutorial will demonstrate how to get started using Enhydra in an MPE/iX environment.

 

We will walk through the installation and setup of an Enhydra environment, including the JDK, the JDBC drivers, and the Enhydra servlet framework. Then we will create a simple Enhydra application, including user interface elements designed in HTML and logic elements written in Java (some prior experience with both HTML and Java is recommended, but not mandatory). We will see how Enhydra makes it easy to maintain a well-organized code base by keeping the business logic separate from the presentation design.

 

Finally, we will connect our Enhydra app to an IMAGE/SQL database using JDBC. We will construct a database abstraction layer as part of this process, showing that a well-designed app can be migrated from one database platform to another with minimal effort. We will see how Enhydra can retrieve data and format it into dynamically-generated web output.

Biographical Sketch:

Jon Diercks has over a decade of experience with HP computers. He has presented various system administration topics at previous HP World and HP e3000 Solutions Symposium events. A frequent contributor to HP3000-L, he is also the author of the "Threads" column appearing regularly in Enterprise Solutions magazine. Jon's first book, the MPE/iX System Administrator's Handbook, was released by Prentice-Hall PTR/HP Professional Books in July 2001.

Introduction

What is Enhydra?

Enhydra is a Java/XML Application Server – a set of APIs and tools built to reduce overhead in designing and deploying web applications.

Why would I want to use Enhydra?

·        Portability

·        Rapid development/deployment (after initial learning curve)

·        Benefits of servlet architecture – performance, session management, etc.

Enhydra Application Architecture

·        Business Logic (Model)

·        HTML storyboard/templates & presentation logic (View)

·        Super-servlet (Controller)

The Enhydra Multiserver

Especially useful for development and testing, the multiserver handles all the functions of a web (http) server, servlet runner and debugger, so everything can be controlled from one place. For scalable and flexible production deployment, you can turn off selected functions of the multiserver and allow other programs like Apache and JRun to handle them – the various tiers can be spread across multiple hardware platforms for security and load balancing.

 

Downloading and Installing

Supporting software

GNU make >=3.75

http://jazz.external.hp.com/src/gnu/gnuframe.html

 JDK >=1.3

http://jazz.external.hp.com/src/java/

unzip

(recommended instead of tar for unpacking)

ftp://nha.co.za/hp3000/unzip/unzip.tar.Z

or mirrored from 3k.com ftp://ftp.3k.com/PROGS/unzip.tar.Z

or http://www.editcorp.com/Personal/Lars_Appel/WebKit2/upload/infozip.tar.Z

Enhydra Application Server

Download

http://enhydra.enhydra.org/software/downloads/

Select the version you want and download the .zip file, not the .tar.gz archive.

Install

Lars Appel’s procedure notes

http://www.editcorp.com/Personal/Lars_Appel/enhydra3.txt

my condensed version (no demos)

MPE/iX:hello manager.sys

:newacct ix,mgr ;pass=acctpw

:altuser mgr.ix ;pass=mgrpw

:altacct ix ;cap=+ph

:newgroup enhydra.ix ;access=(r,x:any; w,a,l,s:gl)

:newuser enhydra.ix ;home=enhydra ;pass=userpw

:altuser enhydra.ix ;cap=+ph,gl

:hello enhydra.ix

:run /bin/sh ;info="-L" ;nmstack=40960000

shell/iX> mkdir temp

shell/iX> cd temp

shell/iX> # upload enhydra3.1.zip

shell/iX> unzip enhydra3.1.zip

shell/iX> # chmod -R u+rwX,go=rX enhydra3.1

shell/iX> mv enhydra3.1 ../v3.1

shell/iX> cd ..

shell/iX> rm -rf temp

shell/iX> cd v3.1

shell/iX> sh configure /usr/local/java/latest

shell/iX> echo /bin/uname –n >/usr/local/bin/hostname

shell/iX> chmod u=rwx,go=rx /usr/local/bin/hostname


Useful symbolic links

shell/iX> cd /usr/local

shell/iX> mkdir enhydra

shell/iX> cd enhydra

shell/iX> ln -s /IX/ENHYDRA/v3.1 ./v3.1                                

shell/iX> ln -s /IX/ENHYDRA/v3.1 ./latest                            

shell/iX> ls -l

total 0

lrwxrwxrwx   1 ENHYDRA.IX        SYS           25 Dec  8 13:34 latest -> /IX/ENHYDRA/v3.1

lrwxrwxrwx   1 ENHYDRA.IX        SYS           21 Dec  8 13:34 v3.1 ->  /IX/ENHYDRA/v3.1


Recommended .profile settings

export CLASSPATH="/usr/local/java/latest/lib"

export PATH="$PATH:/usr/local/java/latest/bin:/usr/local/enhydra/latest/bin"

Creating a simple Enhydra application

appwizard

shell/iX> mkdir ~/apps

shell/iX> cd ~/apps

shell/iX> # initialize appwizard (only needs to be done once)

shell/iX> appwizard –config /usr/local/enhydra/latest

shell/iX> # generate source tree

shell/iX> appwizard en3app -project musicDemo -package musicDemo -root . -client HTML

Examine source tree

shell/iX> cd musicDemo                                                   

shell/iX> ls -FR

 

.:

Makefile      config.mk     input/        readme.html   src/

 

./input:

conf/      start.in

 

./input/conf:

musicDemo.conf.in   servlet/

 

./input/conf/servlet:

servlet.conf.in

 

./src:

Makefile    musicDemo/

 

./src/musicDemo:

Makefile         data/            presentation/

business/        musicDemo.java  

 

./src/musicDemo/business:

Makefile

 

./src/musicDemo/data:

Makefile

 

./src/musicDemo/presentation:

Makefile                    WelcomePresentation.java

RedirectPresentation.java   media/

Welcome.html                options.xmlc

 

./src/musicDemo/presentation/media:

Enhydra.gif   Makefile

make & start

shell/iX> make

shell/iX> cd output

shell/iX> ./start


Connecting to IMAGE/SQL via JDBC

Setup MUSICDBE

If MUSICDBE is not already set up, run IMSQL.SAMPLEDB.SYS steps 1, 3, 4, and 5.

Setup JDBC

See misc notes on last page for JDBC patch info.

:STREAM I00IJDBC.JDBC.SYS

:STREAM I01IJDBC.JDBC.SYS

:STREAM JSTRTMON.JDBC.SYS

Modify musicDemo/input/conf/musicDemo.conf.in

add databasemgr stuff to end of file:

#--------------------------------------------------------------

#                   Database Manager Configuration

#-------------------------------------------------------------------

DatabaseManager.Databases[] = "MUSIC"

DatabaseManager.DefaultDatabase = "MUSIC"

DatabaseManager.Debug = "false"

DatabaseManager.DB.MUSIC.ClassType = "Standard"

DatabaseManager.DB.MUSIC.JdbcDriver = "com.hp.jdbc.allbase.JdbcDriver"

DatabaseManager.DB.MUSIC.Connection.Url = "jdbc:allbase://sys.domain.org/musicdbe.sampledb.sys?"

DatabaseManager.DB.MUSIC.Connection.User = "username.acctname"

DatabaseManager.DB.MUSIC.Connection.Password = "userpass.acctpass"

DatabaseManager.DB.MUSIC.Connection.MaxPreparedStatements = 10

DatabaseManager.DB.MUSIC.Connection.MaxPoolSize = 30

DatabaseManager.DB.MUSIC.Connection.AllocationTimeout = 10000

DatabaseManager.DB.MUSIC.Connection.Logging = false

DatabaseManager.DB.MUSIC.ObjectId.CacheSize = 20

DatabaseManager.DB.MUSIC.ObjectId.MinValue = 1

 

Notes:

·        DatabaseManager.DB.dbname.@ must match DatabaseManager.Databases[] = "dbname"

·        Use your hostname and DBEname in Connection.Url.

·        Use an appropriate username.acctname in Connection.User.

·        Use the correct userpass.acctpass in Connection.Password.


Modify musicDemo/src/musicDemo/presentation/Welcome.html

after </table> add:

The first composer in the MUSIC database is

<b><span id="CName">(nobody)</span></b>.

Modify musicDemo/src/musicDemo/presentation/WelcomePresentation.java

Add imports at top:

import com.lutris.appserver.server.Enhydra;

import com.lutris.appserver.server.sql.*;

import java.sql.*;

 

Add this block at top of run(), after “byte[] buffer;”:

String cName = null;

 

try {

  DBConnection conn =

    Enhydra.getDatabaseManager().allocateConnection();

  ResultSet rs = conn.executeQuery(

    "SELECT COMPOSERNAME FROM MUSIC.COMPOSERS");

  if (null != rs && rs.next())   

    cName = rs.getString("COMPOSERNAME");

} catch (Exception e) { e.printStackTrace(); }

 

And after welcome.getElementTime()…

welcome.setTextCName(cName);

 

Notes:

·        Normally shouldn’t do this in the presentation layer, move to business and/or data subdirectories instead.

·        Create an abstraction layer, treat database as an object.

·        allocateConnection() once, not each time you want to query.

 

make & start

Where to go from here

·        Read

·        Experiment

·        Expand


Misc notes

Useful documents

Enhydra Documentation – from Lutris

http://enhydra.enhydra.org/software/documentation/index.html

Enhydra Journal

Registration required (free) for password to access current issue.

http://www.lutris.com/newsletter/index.html

Some tidbits from the Enhydra mail list archive & FAQ

·        header/footer node replacement - http://enhydra.enhydra.org/project/mailingLists/enhydra/199911/msg00223.html

·        How to set HTMLTitleElement text - http://enhydra.enhydra.org/project/mailingLists/enhydra/199911/msg00223.html

·        Compile-time Server Side Includes (requires enhydra 3.1b2 or later) - http://www.lutris.com/journal/October2000/articles/enhydraFAQ.html#one

JDBC NullPointerException

In early testing, I encountered a bug in the 6.5 FOS JDBC drivers. Something about the way Enhydra's database-abstraction layer accessed the JDBC driver was triggering a NullPointerException. Patch JDBLXB6A is now reportedly available from the RC as a beta patch, and it should include version 1_1_3 of DRIVERJ.JDBC.SYS. This is a jar-format archive containing the various class files needed for java programs to access databases as a JDBC client connecting to the HP IMAGE/SQL JDBC server. Although it's a 6.5 patch, I don't think there should be any reason not to use the same client classes when talking to JDBC on other versions (haven't tried though).

LDAP client APIs for Java

If you’re using JDK 1.2.2 and want your enhydra app to access LDAP directories, you’ll need jndi.jar and ldap.jar from http://java.sun.com/products/jndi/index.html (install them in /usr/local/java/latest/jre/lib/ext/).

cygwin Unix-style shell for Windows

If you install a copy of Enhydra on a Windows system for offline development/testing, you will also need the cygwin Unix-style shell for Windows. The standard Enhydra 3.0.1 installer for Windows also includes cygwin, but if you install Enhydra manually (such as for a beta release) you may need to get cygwin separately from http://www.cygwin.com/.

DODS

So far, I haven’t done much with this. It requires a GUI, so you can’t run it directly on MPE. It can scan an existing database, but it expects there to be standard-named sequential index key fields on each table if you’re going to do any code generation from it. Probably nice if you’re starting from scratch, but kind of a pain to shoehorn into an existing DB.