Closing the session, Defining the connection url, Establishing the connection – HP Integrity NonStop J-Series User Manual

Page 187: Defining the hibernate dialect for sql/mx database, Opening a session for database operation

Advertising
background image

NOTE:

To view the complete configuration snippet of the hibernate.cfg.xml file, see

“JDBC

Configuration” (page 227)

.

Closing the Session

Once the database operation is complete, close the session to deallocate the memory.

Add the following line of code when you complete the database operation.

session.close();

Configuring JDBC Type 4 Driver for SQL/MX Database using hibernate.properties

To complete the database operation in a Hibernate application using the JDBC Type 4 driver for
the SQL/MX database, complete the following steps:

1.

Specifying the JDBC Type 4 Driver for SQL/MX Database

2.

“Defining the Connection URL” (page 187)

3.

“Establishing the Connection” (page 187)

4.

“Defining the Hibernate Dialect for SQL/MX Database” (page 187)

5.

“Opening a Session for Database Operation” (page 187)

6.

“Specifying the Mapping Resources” (page 188)

7.

“Closing the Session” (page 188)

Specifying the JDBC Type 4 Driver for SQL/MX Database

To specify the JDBC Type 4 driver for SQL/MX database, enter
com.tandem.t4jdbc.SQLMXDriver

as the JDBC Type 4 driver class for the SQL/MX database

in the hibernate.properties file as shown:

hibernate.connection.driver_class com.tandem.t4jdbc.SQLMXDriver

Defining the Connection URL

After you have specified the JDBC Type 4 driver, enter the location of the SQL/MX server. URLs
referring to SQL/MX use the jdbc: protocol and have the server host, port number embedded
within the URL.

To define the connection URL, enter jdbc:t4sqlmx://<HP NonStop System IP
Address>:<Port No.>

as the connection URL for the SQL/MX database in the

hibernate.properties

file as shown:

hibernate.connection.url jdbc:t4sqlmx://<HP NonStop System IP Address>:<Port No.>

Establishing the Connection

To establish the connection, specify the username and password of your NonStop system in the
hibernate.properties

as shown.

hibernate.connection.username <HP NonStop Username>
hibernate.connection.password <HP NonStop Password>

Defining the Hibernate Dialect for SQL/MX Database

Enter org.hibernate.dialect.SqlmxDialect as the class name of a Hibernate dialect file
in the hibernate.properties file as shown below.

hibernate.dialect org.hibernate.dialect.SqlmxDialect

This property allows Hibernate to generate SQL optimized for SQL/MX database.

Opening a Session for Database Operation

To open a new session for database transaction, complete the following steps:

1.

“Configuring SessionFactory in your Java Program” (page 188)

2.

“Creating a New Session from the SessionFactory in Java” (page 188)

Hibernate Framework Configurations for NonStop Systems

187

Advertising
This manual is related to the following products: