Closing the session, Defining the connection url, Hibernate.properties – HP Integrity NonStop H-Series User Manual
Page 324
...
...
...
...
...
NOTE:
The above configuration uses the
hibernate-configuration-3.0.dtd
file.
Creating a New Session from the SessionFactory in Java
Add the following to create a new session from the
SessionFactory
:
SessionFactory sessionFactory;
Configuration cfg = new Configuration().configure();
sessionFactory = cfg.buildSessionFactory();
Session session = sessionFactory.openSession();
NOTE:
To view the complete configuration snippet of the
hibernate.cfg.xml
file, see the
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.
3.
4.
Defining the Hibernate Dialect for SQL/MX Database
5.
Opening a Session for Database Operation
6.
Specifying the Mapping Resources
7.
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://
Address>:
as the connection URL for the SQL/MX database in the
hibernate.properties
file as shown:
hibernate.connection.url jdbc:t4sqlmx://
324
Configuring Hibernate Applications on NonStop Systems