Good Day!
I fail to configure Hibernate properly to connect it to remote Oracle Server.
Hibernate version:
2.1.7
Code between sessionFactory.openSession() and session.close():
Session session = getSessionFactory().openSession();
Transaction tx = session.beginTransaction(); //exception
tx.commit();
session.close();
Full stack trace of any exception that occurs:
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:289)
at net.sf.hibernate.impl.SessionImpl.connect(SessionImpl.java:3361)
at net.sf.hibernate.impl.SessionImpl.connection(SessionImpl.java:3321)
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:2251)
at rjoker.th1.test.TestApplication1.method5(TestApplication1.java:148)
at rjoker.th1.test.TestApplication1.main(TestApplication1.java:72)
Name and version of the database you are using:
Oracle 8.1.7.4.0
[b]Comments[b]
Without Hibernate there is no problems to connect like this:
DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
DriverManager.getConnection("jdbc:oracle:thin:@oradev:10521:D", "aaa", "bbb");
But with Hibernate I'm getting UnsupportedOperationException with string "The user must supply a JDBC connection" trying to session.beginTransaction() or session.save(...) for example. So real access to the database doesn't work.
Starting Hibernate log contains the following string:
WARN UserSuppliedConnectionProvider:25 - No connection properties specified - the user must supply JDBC connections
If I provide connection manualy everything works:
DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
_connection = DriverManager.getConnection("jdbc:oracle:thin:@oradev:10521:D", "aaa", "bbb");
Session session = getSessionFactory().openSession(_connection);
Transaction tx = session.beginTransaction(); //no exception
tx.commit();
session.close();
So, apparently, something wrong with hibernate configuration file.
I'm using hibernate.properties only. I have no hibernate.cfg.xml.
[b]hibernate.properties[b]
hibernate.query.substitutions true 1, false 0, yes 'Y', no 'N'
hibernate.dialect net.sf.hibernate.dialect.OracleDialect
hibernate.connection.driver_class oracle.jdbc.driver.OracleDriver
hibernate.connection.username aaa
hibernate.connection.password bbb
hibernate.connection.url jdbc:oracle:thin:@oradev:10521:D
hibernate.connection.pool_size 1
hibernate.proxool.pool_alias pool1
hibernate.jdbc.batch_size 0
hibernate.max_fetch_depth 1
hibernate.jdbc.use_streams_for_binary true
hibernate.jdbc.batch_versioned_data true
hibernate.cache.region_prefix hibernate.test
hibernate.cache.use_query_cache true
hibernate.cache.provider_class net.sf.hibernate.cache.EhCacheProvider
I'm using Java and Hibernate only. There is no containers or frameworks around for the moment. (planning to work with Spring Framework).
I think that due to wrong hibernate.properties Hibernate decides to user UserSuppliedConnectionProvider. But for normal work it shoul choose another ConnectionProvider because all the connection information is included in the hibernate.properties. May be I forgot to set some settings in the hibernate.properties?
Thanks a lot for your help!
|