-->
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.  [ 2 posts ] 
Author Message
 Post subject: Configuring without hibernate.cfg.xml in hibernate2
PostPosted: Sun May 29, 2016 10:32 am 
Newbie

Joined: Sun May 29, 2016 10:17 am
Posts: 1
I am using hibernate.properties file with following entries :

hibernate.connection.driver_class = com.mysql.jdbc.Driver
hibernate.connection.url = jdbc:mysql://localhost:3306/Spitter
hibernate.connection.username = root
hibernate.connection.password =
hibernate.dialect = net.sf.hibernate.dialect.MySQLDialect

and have put the file in src folder(under a java project in eclipse).
but when i run the following snippet of code :::::

Configuration cfg = new Configuration();
cfg.addResource("hello/Message.hbm.xml");
cfg.setProperties( System.getProperties() );
SessionFactory sessions = cfg.buildSessionFactory();



Session session = sessions.openSession();
Transaction tx = session.beginTransaction();
Message message = new Message("Hello World");
session.save(message);

tx.commit();
session.close();



i am getting following exception ::::::::

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:292)
at net.sf.hibernate.impl.SessionImpl.connect(SessionImpl.java:3373)
at net.sf.hibernate.impl.SessionImpl.connection(SessionImpl.java:3333)
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:2252)


Please explain where i am going wrong.


Top
 Profile  
 
 Post subject: Re: Configuring without hibernate.cfg.xml in hibernate2
PostPosted: Mon May 30, 2016 12:59 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
Why are you using Hibernate 2? We have Hibernate 5 now.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.