maxWait="5000"
username="osmsusr"
url="jdbc:oracle:thin:@IP_OR_HOSTNAME_OF_DB_SERVER:1521:osmsdb_ora" maxActive="15"/>
</Context>
Where: IP_OR_HOSTNAME_OF_DB_SERVER is the MySQL or Oracle database server name or IP address.
3.Add the Hibernate3 JAR files to the application library by copying the following files from the Hibernate3 installation directory to
hibernate3.jar
asm.jar asm-attrs.jar antlr-2.7.6rc1.jar
4.Hibernate uses a configuration file named hibernate.cfg.xml to obtain the database connection information and mapping file information.
Create a Hibernate configuration file named
For a MySQL database server:
<?xml version='1.0'
<property name="show_sql">true</property>
<property name="connection.datasource">java:comp/env/MySqlDS</property> <property name="dialect">org.hibernate.dialect.MySQLDialect</property> <mapping resource="com/hp/osms/hibernate/Users.hbm.xml" />
For an Oracle database server:
<?xml version='1.0'
Installing,Configuring,and Managing Web Application Server Middleware Stack Components 33
<property name="show_sql">true</property>
<property name="connection.datasource">java:comp/env/OracleDS</property> <property name="dialect">org.hibernate.dialect.Oracle9Dialect</property> <mapping resource="com/hp/osms/hibernate/Users.hbm.xml" />
NOTE: The values of OracleDS and MySqlDS are the data source names that are configured in the Tomcat Web server.
5.In Hibernate, a unit of work is named a session that is managed by SessionFactory.
To retrieve data for a session, create a utility named HibernateSessionFactory.java located in
38