-->
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: Hibernate Programatic and XML Configuration Error
PostPosted: Mon Jan 30, 2006 12:41 pm 
Newbie

Joined: Fri Dec 30, 2005 12:47 pm
Posts: 11
Hibernate version: 3.0

hi i am trying to use both hibernate configuration xml for mappins and common properties and programtic to past database connection property, this is the code:

cfg variable is a serialized object that contain the configuration properties

Code:

configuration = new Configuration();

Properties properties = new Properties();
properties.put("connection.driver_class",cfg.getDbDriver());
properties.put("connection.url",cfg.getDatabaseURL());
properties.put("connection.username",cfg.getDbUser());
properties.put("connection.password",cfg.getDbPassword());
properties.put("hibernate.dialect","org.hibernate.dialect.MySQLDialect");

configuration.setProperties(properties);
         
sessionFactory = configuration.configure().buildSessionFactory();



this is the hibernate.cfg.xml file:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
      "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
      "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
      
<hibernate-configuration>
   <session-factory>
      
        <property name="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</property>
       
          
        <property name="hibernate.connection.release_mode">auto</property>
             
   
        <property name="show_sql">true</property>
        <property name="hibernate.format_sql">true</property>
     
        <property name="hibernate.hbm2ddl.auto">update</property>
             
   
      <mapping resource="siembra/futuro/model/Beneficiario.hbm.xml" />
      <mapping resource="siembra/futuro/model/DatosConyugue.hbm.xml" />
      <mapping resource="siembra/futuro/model/DatosFinancieros.hbm.xml" />
      <mapping resource="siembra/futuro/model/DatosNegocio.hbm.xml" />
      <mapping resource="siembra/futuro/model/EntidadAportante.hbm.xml" />
      <mapping resource="siembra/futuro/model/GES.hbm.xml" />
      <mapping resource="siembra/futuro/model/GSB.hbm.xml" />
/>
      
   </session-factory>
</hibernate-configuration>

When the buildSessionFactory() is called throw this exception:

xception in thread "main" java.lang.UnsupportedOperationException: The user must supply a JDBC connection
at org.hibernate.connection.UserSuppliedConnectionProvider.getConnection(UserSuppliedConnectionProvider.java:30)
at org.hibernate.jdbc.AbstractBatcher.openConnection(AbstractBatcher.java:424)
at org.hibernate.jdbc.JDBCContext.connect(JDBCContext.java:149)
at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:95)
at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:49)
at org.hibernate.transaction.JDBCTransactionFactory.beginTransaction(JDBCTransactionFactory.java:19)
at org.hibernate.jdbc.JDBCContext.beginTransaction(JDBCContext.java:212)
at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1015)
at siembra.futuro.persistent.HibernateUtil.beginTransaction(HibernateUtil.java:185)


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.