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)