-->
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.  [ 4 posts ] 
Author Message
 Post subject: Problem getting connection from Datasource in WSAD 5.1
PostPosted: Wed Mar 17, 2004 5:03 pm 
Beginner
Beginner

Joined: Mon Mar 08, 2004 6:09 pm
Posts: 20
Hi people.
I'm trying to use Hibernate 2.1.2 with WSAD 5.1 and oracle 9i.
The problem is in the SessionFactory.buildSessionFactory() method, because, inside in the DatasourceConnectionProvider.getConnection() method when trying to get the connection from the datasource object (wich isn't null) it throw me out without any exception, and I return to the finally clause in the class where I call buildSessionFactory.

I don't know what could happening, because I follow all the tutorials to use Hibernate with WSAD and the tutorials to create Oracle Datasources.

Please help me!!!

Thank you very much!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 17, 2004 5:40 pm 
Regular
Regular

Joined: Wed Jan 07, 2004 5:16 pm
Posts: 65
Location: CA, USA
Have you configured your datasource in your hibernate.cfg.xml file?

For example, something like this:
Code:
        <property name="hibernate.connection.datasource">jdbc/ds1</property>       
        <property name="hibernate.connection.username">userid</property>
        <property name="hibernate.connection.password">password</property>
           
        <property name="dialect">Class for Oracle dialect here</property>



The code to then get the Session Factory should be something like this:
Code:
sessionFactory =
     new Configuration(  ).configure(  ).buildSessionFactory(  );



Kevin Hooke


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 18, 2004 10:34 am 
Beginner
Beginner

Joined: Mon Mar 08, 2004 6:09 pm
Posts: 20
This is the content of my hibernate.properties file:
Code:
hibernate.query.substitutions true 1, false 0, yes 'Y', no 'N'
hibernate.connection.datasource java:comp/env/jdbc/OracleDatasource
hibernate.connection.provider_class net.sf.hibernate.connection.DatasourceConnectionProvider
hibernate.transaction.manager_lookup_class net.sf.hibernate.transaction.WebSphereTransactionManagerLookup
hibernate.jdbc.batch_size 0
hibernate.jdbc.use_streams_for_binary true
hibernate.default_schema SEGURIDAD_ADMINISTRACION
hibernate.max_fetch_depth 1
hibernate.cache.use_query_cache true
hibernate.cache.provider_class net.sf.hibernate.cache.HashtableCacheProvider


To create the SessionFactory I'm using this code:
Code:
InputStream streamMAPPING = SessionController.class.getResourceAsStream(MAPPING_WF);
            Configuration cfg = new Configuration().addInputStream(streamMAPPING)
                .addClass(Tenedor.class)
                .addClass(TipoTenedor.class);
                   
            Properties hibernateConfig = new Properties();
            hibernateConfig.load(SessionController.class.getResourceAsStream(HIBERNATE_CONFIG));
            cfg.setProperties(hibernateConfig);
            sessions = cfg.buildSessionFactory();

following the hibernate source for the cfg.buildSessionFactory() and after a few methods I enter in the class SettingsFactory then in the line 72 over Connection conn = connections.getConnection(); when I enter there (the class is: DatasourceConnectionProvider) the method say:
Code:
public Connection getConnection() throws SQLException {
      if (user != null || pass != null) {
         return ds.getConnection(user, pass);
      }
      else {
         return ds.getConnection();
      }
   }

well.. we're near the problem... the ds object isn't null, his type is
Code:
com.ibm.ws.rsadapter.jdbc.WSJdbcDataSource


and when trying to return the connection, there is no exceptions and jump directly to finally clause in the class where I'm creating the SessionFactory.

Please help, I'm stuck a few days ago with this problem!

Thank you very much!!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 18, 2004 2:19 pm 
Beginner
Beginner

Joined: Mon Mar 08, 2004 6:09 pm
Posts: 20
Problem Solved!!!

It was the Oracle Driver. The JRE of WAS 5.1.0 is 1.31xx and the driver I'm using needs the 1.42xx.


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

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.