Running the Hibernate Application with Oracle

I am using the default database that comes with the Oracle implementation.
The username/password for this database is scott/tiger and the SID I have presumed is mattiz (This is set during Oracle installation.).
I changed only one file in the application described in the previous blog, that is, spring-servlet.xml. I also copied the oracle driver to server/default/lib. (The driver can be got from the Oracle website.)
Change is only to one configuration file: spring-servlet.xml.
Here is the source for the modified spring-servlet.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!-- - Application context definition for "springapp" DispatcherServlet. -->
	<!-- Business Layer beans definition -->
	<bean id="viewResolver"
		<property name="viewClass">
	<!-- Oracle DataSource Definition -->
	<bean id="dataSourceOracle" class="org.apache.commons.dbcp.BasicDataSource"
		<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
		<property name="url" value="jdbc:oracle:thin:@localhost:1521:mattiz" />
		<property name="username" value="scott" />
		<property name="password" value="tiger" />
	<!-- Hibernate SessionFactory Definition -->
	<bean id="sessionFactory"
		<property name="mappingJarLocations">
		<property name="hibernateProperties">
				<prop key="hibernate.dialect">
				<prop key="hibernate.show_sql">true</prop>
		<property name="dataSource">
			<ref local="dataSourceOracle" />
	<!-- Hibernate Template Defintion -->
	<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
		<property name="sessionFactory">
			<ref local="sessionFactory" />
		<property name="cacheQueries" value="false" />
		<property name="jdbcExceptionTranslator">
			<ref local="jdbcExceptionTranslator" />
	<bean id="jdbcExceptionTranslator"
		<property name="dataSource">
			<ref local="dataSourceOracle" />

Get source code here Hibernate_with_Oracle

About cuppajavamattiz
Matty Jacob - Avid technical blogger with interests in J2EE, Web Application Servers, Web frameworks, Open source libraries, Relational Databases, Web Services, Source control repositories, ETL, IDE Tools and related technologies.

Comments are closed.

%d bloggers like this: