Customizing jpetstore, Added file, Setdatabase.java – HP Integrity NonStop J-Series User Manual

Page 139: Modified files, Item.xml, Added file modified files

Advertising
background image

Customizing JPetStore

To customize the JPetStore sample application to run on NonStop systems, one file was added and
five files were modified.
Added File:

SetDatabase.java

Modified Files:

Item.xml

dataAccessContext-local.xml

jdbc.properties

Order.xml

Pom.xml

Added File

The following file was added to customize JPetStore:

SetDatabase.java

(<My SASH Home>\spring\samples\jpetstore\src\main\java\org\
springframework\samples\jpetstore\property\SetDatabase.java)

The SetDatabase.java file was created, in the
org.springframework.samples.jpetstore.property

package, for adding customized

connection properties to the JDBC driver.
The SetDatabase.java class file appeared as:

package org.springframework.samples.jpetstore.property;
import org.apache.commons.dbcp.BasicDataSource;
public class SetDatabase extends BasicDataSource{
private String catalog;
private String schema;
public void setCatalog(String catalog) {
this.catalog=catalog;
addConnectionProperty("catalog",this.catalog);
}

public void setSchema(String schema) {
this.schema=schema;
addConnectionProperty("schema",this.schema);
}

Modified Files

The following files were modified to customize JPetStore:

Item.xml

(<My SASH Home>\spring\samples\jpetstore\src\main\java\org\
springframework\samples\jpetstore\dao\ibatis\Item.xml)

This is the Ibatis mapping file used to automate the mapping between database tables and Java
objects. The mappings are decoupled from the application logic by packaging the SQL statements
in XML configuration files.
In Ibatis, the term 'as value' is used to select a single primitive value from the database. Because
'value’ is a keyword in the SQL/MX database, 'as value' could not be used and hence Item.xml
was modified.

Customizing JPetStore

139

Advertising
This manual is related to the following products: