Jdbc driver for sql/mx database – HP Integrity NonStop J-Series User Manual

Page 181

Advertising
background image

JDBC Driver for SQL/MX Database

The JDBC driver to be used when a Hibernate application connects to the SQL/MX database must
be specified in the hibernate.cfg.xml or hibernate.properties file created while
developing the Hibernate application.

This section discusses the following:

“Configuring the JDBC Type 2 Driver for SQL/MX Database” (page 181)

“Configuring JDBC Type 4 Driver for SQL/MX Database” (page 185)

Configuring the JDBC Type 2 Driver for SQL/MX Database

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

“Configuring the JDBC Type 2 Driver for the SQL/MX Database using hibernate.cfg.xml”
(page 181)

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

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

The advantage of using this approach is the externalization of mapping file names to the
configuration. To complete the database operation in a Hibernate application using the JDBC Type
2 driver for the SQL/MX database, complete the following steps:

1.

“Specifying the JDBC Type 2 Driver for SQL/MX Database” (page 181)

2.

“Defining the Connection URL” (page 182)

3.

“Establishing the Connection” (page 182)

4.

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

5.

“Specifying the Mapping Resources” (page 182)

6.

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

7.

“Closing the Session” (page 183)

Specifying the JDBC Type 2 Driver for SQL/MX Database

One of the advantages of using the JDBC driver is that the SQL/MX database server does not
require any changes. Instead, the JDBC Type 2 driver translates calls written in Java to the specific
format required by the database server.

To specify the JDBC Type 2 driver, enter com.tandem.sqlmx.SQLMXDriver as the JDBC Type
2 driver class for the SQL/MX database in the hibernate.cfg.xml file under the
<session-factory>

tag as shown:

<?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.sqlmx.SQLMXDriver</property>
...
...
...
...
</session-factory>
</hibernate-configuration>

NOTE:

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

“Opening a Session

for Database Operation” (page 182)

.

Hibernate Framework Configurations for NonStop Systems

181

Advertising
This manual is related to the following products: