-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: java.lang.RuntimeException: The session factory has not been
PostPosted: Thu Jun 10, 2004 2:27 pm 
Beginner
Beginner

Joined: Sun Sep 07, 2003 9:04 am
Posts: 48
Hello forum, first of all thanks to good guys who are using there time to help.
here is the code i am trying to run.

public class test4 {

public static void main(String[] args) throws Exception {

// load the configuration file
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
String url = "jdbc:oracle:thin:@localhost:1521:pusdb";
Configuration cfg = new Configuration();
SessionFactory s = cfg.buildSessionFactory();
Connection con = DriverManager.getConnection(url, "MUFDB","sofus1");
Session ss = s.openSession(con);
PersonsDAO dao = new PersonsDAO();
Transaction tx = ss.beginTransaction();
// find all people
List people = dao.findAll();
// find a single person
Integer id = new Integer(3);
Persons person = dao.load(id);
// update the person
person.setFirstName("dld");

dao.update(person);
tx.commit();
ss.close();
//dao.delete(id);
} catch (HibernateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// delete the person

}
}
*************************************************************
here is my config file
<?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>
<!-- datasource connection properties -->
<property name="connection.datasource">jdbc:oracle:thin:@localhost:1521:PUSDB</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="Persons.hbm.xml" />
<mapping resource="Reservations.hbm.xml" />
</session-factory>
</hibernate-configuration>
*
**********************************************************
Here is the errore i am getting

14:35:22,557 INFO Environment:462 - Hibernate 2.1.3
14:35:22,567 INFO Environment:496 - loaded properties from resource hibernate.properties: {hibernate.connection.username=MUFDB, hibernate.connection.password=sofus1, hibernate.cglib.use_reflection_optimizer=true, hibernate.dialect=net.sf.hibernate.dialect.OracleDialect, hibernate.connection.url=jdbc:oracle:thin:@localhost:1521:pusdb", hibernate.connection.driver_class=oracle.jdbc.driver.OracleDriver}
14:35:22,577 INFO Environment:519 - using CGLIB reflection optimizer
14:35:22,587 INFO Configuration:613 - processing one-to-many association mappings
14:35:22,587 INFO Configuration:622 - processing one-to-one association property references
14:35:22,597 INFO Configuration:647 - processing foreign key constraints
14:35:22,657 INFO Dialect:82 - Using dialect: net.sf.hibernate.dialect.OracleDialect
14:35:22,747 INFO SettingsFactory:62 - Use outer join fetching: true
14:35:22,767 INFO DriverManagerConnectionProvider:42 - Using Hibernate built-in connection pool (not for production use!)
14:35:22,767 INFO DriverManagerConnectionProvider:43 - Hibernate connection pool size: 20
14:35:22,767 INFO DriverManagerConnectionProvider:77 - using driver: oracle.jdbc.driver.OracleDriver at URL: jdbc:oracle:thin:@localhost:1521:pusdb"
14:35:22,767 INFO DriverManagerConnectionProvider:78 - connection properties: {user=MUFDB, password=sofus1}
14:35:22,777 INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
14:35:23,117 WARN SettingsFactory:95 - Could not obtain connection metadata
java.sql.SQLException: Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
The Connection descriptor used by the client was:
localhost:1521:pusdb"

at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:124)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:279)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:318)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:343)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:147)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:31)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:545)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at net.sf.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:101)
at net.sf.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:72)
at net.sf.hibernate.cfg.Configuration.buildSettings(Configuration.java:1132)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:766)
at test4.main(test4.java:37)
14:35:23,127 INFO SettingsFactory:102 - Use scrollable result sets: false
14:35:23,127 INFO SettingsFactory:105 - Use JDBC3 getGeneratedKeys(): false
14:35:23,127 INFO SettingsFactory:108 - Optimize cache for minimal puts: false
14:35:23,127 INFO SettingsFactory:117 - Query language substitutions: {}
14:35:23,137 INFO SettingsFactory:128 - cache provider: net.sf.ehcache.hibernate.Provider
14:35:23,147 INFO Configuration:1093 - instantiating and configuring caches
14:35:23,348 INFO SessionFactoryImpl:119 - building session factory

14:35:24,179 INFO SessionFactoryObjectFactory:82 - no JNDI name configured


java.lang.RuntimeException: The session factory has not been initialized.
at TEST.base._BaseRootDAO.getSessionFactory(_BaseRootDAO.java:86)
at TEST.base._BaseRootDAO.createSession(_BaseRootDAO.java:116)
at TEST.base._BaseRootDAO.createSession(_BaseRootDAO.java:107)
at TEST.base._BaseRootDAO.getSession(_BaseRootDAO.java:99)
at TEST.base._BaseRootDAO.findAll(_BaseRootDAO.java:184)
at test4.main(test4.java:44)
Exception in thread "main


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.