Hello forum, firstly thanks for your time.
I have installed hibernate synchronizer on eclipse-SDK-3.0M9-win32 then hook to a oracle10g db, then generated the files of 3 tables.
the hbh.xml, the java files.
then genrated the apping file cfg.xml.
but the tried this small example.
I am running it inside eclipse
the structure of problem
1: test.java
2:cfg.xml
3: the error message produced by running ttest.java
*************************************************************
public class test {
public static void main(String[] args) throws Exception {
Persons p = new Persons();
p.setId(Integer.getInteger("2"));
p.setFirstName("pus");
// 2. Fire up Hibernate
Configuration cfg = new Configuration ().addClassPersons.class)
.addClass(Reservations.class)
.addClass(Flights.class);
SessionFactory sf = cfg.buildSessionFactory();
// 3. Open Session
Session sess = sf.openSession();
// 4. Save Product and close Session
Transaction t = sess.beginTransaction();
sess.save(p);
t.commit();
sess.close();
System.out.println(p);
}
}
*************************************************************
here is my cfg.xml
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration
PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">
<hibernate-configuration>
<session-factory name="java:comp/env/hibernate/SessionFactory">
<!-- datasource connection properties -->
<property name="connection.datasource">
java:comp/env/hibernate/SessionFactory
</property>
<!-- dialect for Oracle (any version) -->
<property name="dialect">
net.sf.hibernate.dialect.OracleDialect
</property>
<property name="hibernate.show_sql">false</property>
<property name="hibernate.use_outer_join">true</property>
<property name="hibernate.transaction.factory_class">
net.sf.hibernate.transaction.JBossTransactionManagerLookup
</property>
<property name="jta.UserTransaction">
java:comp/UserTransaction
</property>
<mapping resource="Flights.hbm.xml" />
<mapping resource="Jultest.hbm.xml" />
<mapping resource="Persons.hbm.xml" />
<mapping resource="Reservations.hbm.xml" />
</session-factory>
</hibernate-configuration>
************************************************************
Error message
(impl.SessionFactoryObjectFactory 82 ) no JNDI name configured
java.lang.UnsupportedOperationException: The user must supply a JDBC connection
at net.sf.hibernate.connection.UserSuppliedConnectionProvider.getConnection(UserSuppliedConnectionProvider.java:32)
at net.sf.hibernate.impl.BatcherImpl.openConnection(BatcherImpl.java:278)
at net.sf.hibernate.impl.SessionImpl.connect(SessionImpl.java:3297)
at net.sf.hibernate.impl.SessionImpl.connection(SessionImpl.java:3277)
at net.sf.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:40)
at net.sf.hibernate.transaction.JDBCTransactionFactory.beginTransaction(JDBCTransactionFactory.java:19)
at net.sf.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:2220)
at src.test.main(test.java:37)
Exception in thread "main"
|