I use hibernate to connect Oracle data base. The program got error while connecting to Oracle database.
I run from debugger and found out the SessionFactoryName is null. Is it causing the connection problem.??
See my code below
==========================
==========
==========
==========
==========
=========
Configuration configuration = new Configuration();
configuration.setEntityRes
olver(new ImportFromClasspathEntityR
esolver())
;
sessionFactoryName = configuration.getProperty(
Environmen
t.SESSION_
FACTORY_NA
ME);
String txn_strategy = configuration.getProperty(
Environmen
t.TRANSACT
ION_STRATE
GY);
if (sessionFactoryName != null) {
configuration.buildSession
Factory();
} else {
sessionFactory = configuration.buildSession
Factory();
}
public static void beginTransaction() throws InfrastructureException {
try {
getSessionFactory().getCur
rentSessio
n().beginT
ransaction
(); <=== error here
} catch (Exception e) {
throw new InfrastructureException(e)
;
}
}
configuration file
===========
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection
.driver_cl
ass">oracl
e.jdbc.dri
ver.Oracle
Driver</pr
operty>
<property name="hibernate.connection
.url">jdbc
:oracle:th
in:@111.22
2.40.107:1
521:dev</p
roperty>
<property name="connection.username"
>myUser</p
roperty>
<property name="connection.password"
>myPasswor
d</propert
y>
<property name="connection.pool_size
">1</prope
rty>
<property name="transaction.factory_
class">org
.hibernate
.transacti
on.JDBCTra
nsactionFa
ctory</pro
perty>
<property name="current_session_cont
ext_class"
>thread</p
roperty>
<property name="hibernate.dialect">o
rg.hiberna
te.dialect
.OracleDia
lect</prop
erty>
<property name="connection.isolation
">1</prope
rty>
<property name="hibernate.connection
.release_m
ode">auto<
/property>
<property name="show_sql">false</pro
perty>
<property name="hibernate.format_sql
">true</pr
operty>
<property name="hibernate.jdbc.batch
_size">10<
/property>
<property name="hibernate.cglib.use_
reflection
_optimizer
">true</pr
operty>
<property name="cache.use_second_lev
el_cache">
false</pro
perty>
</session-factory>
</hibernate-configuration>
==
Please advise and pinpoint where it goes wrong.
Many thanks in advance
Start Free Trial