Configuring jdbc type 4 driver for sql/mx database, Defining the connection url – HP Integrity NonStop J-Series User Manual

Page 185

Advertising
background image

session.close();

Configuring JDBC Type 4 Driver for SQL/MX Database

In a typical Hibernate application, you can configure the JDBC Type 4 driver for SQL/MX database
using either one of the following preferred options:

“Configuring JDBC Type 4 Driver for SQL/MX Database using hibernate.cfg.xml”
(page 185)

“Configuring JDBC Type 4 Driver for SQL/MX Database using hibernate.properties”
(page 187)

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

The advantage of using this approach is the externalization of mapping file names to configuration.
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” (page 185)

2.

“Defining the Connection URL” (page 185)

3.

Establishing the Connection

4.

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

5.

“Specifying the Mapping Resources” (page 186)

6.

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

7.

“Closing the Session” (page 187)

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 name of the JDBC Type 4 driver class for the

SQL/MX database in the hibernate.cfg.xml file under the <session-factory> tag as
shown below.

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
<session-factory>
<property name="connection.driver_class">com.tandem.t4jdbc.SQLMXDriver</property>
...
...
...
...

</session-factory>
</hibernate-configuration>

NOTE:

The significance of the <session-factory> tag is discussed in

“Opening a Session

for Database Operation” (page 186)

.

Defining the Connection URL

After you have specify 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.cfg.xml

under the <session-factory> tag as shown:

<property name="connection.url">jdbc:t4sqlmx://<HP NonStop System IP Address>:<Port No.></property>

Hibernate Framework Configurations for NonStop Systems 185

Advertising
This manual is related to the following products: