-->
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.  [ 6 posts ] 
Author Message
 Post subject: Newbie question on configuration
PostPosted: Sat Jan 03, 2004 7:39 pm 
Newbie

Joined: Sat Jan 03, 2004 6:34 pm
Posts: 4
I'm trying to write a very simple Hibernate application. I dont use ant kind of web server or application server etc, just a plain , vanilla hiberante example. I copied some example source from various tutorials but seem to have a problem about sessions. I always got "The user must supply a JDBC connection" exception and program exits.

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:257)
at net.sf.hibernate.impl.SessionImpl.connect(SessionImpl.java:3157)
at net.sf.hibernate.impl.SessionImpl.connection(SessionImpl.java:3140)
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:2158)
at example.HibernateTest.main(HibernateTest.java:40)
Exception in thread "main"



I use mysql and eclipse and here is my hibernate.properties file (I have the tables and database required for classes):

hibernate.connection.username=****
hibernate.connection.password=****
hibernate.dialect=net.sf.hibernate.dialect.MySQLDialect
hibernate.connection.url=jdbc\:mysql\://localhost/test
hibernate.connection.driver_class=org.gjt.mm.mysql.Driver
hibernate.connection.pool_size=3

any ideas on what went wrong?
thanks in advance.

Mehmet.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 03, 2004 8:13 pm 
Expert
Expert

Joined: Tue Sep 16, 2003 4:06 pm
Posts: 318
Location: St. Petersburg, Russia
You are not saying which Hibernate version you are using. I just took look at HB 2.1beta6 sources. Hibernate falls to UserSuppliedConnectionProvider only if you do not have "hibernate.connection.url" property defined.

Since you are stating you have this property defined, the only idea I have - your hibernate.properties file is not parsed. Are you sure it is in classpath?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 03, 2004 8:19 pm 
Expert
Expert

Joined: Tue Sep 16, 2003 4:06 pm
Posts: 318
Location: St. Petersburg, Russia
Btw, try enabling debug log. Hibernate will put alot of useful info there...


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 04, 2004 6:05 pm 
Newbie

Joined: Sat Jan 03, 2004 6:34 pm
Posts: 4
I have looked at the logs and I found out that it could not find hiberanete.properties file.

As I put the hibernate.properties file to the binary directory it worked , but I dont understand this, it was in the root directory of project and as far as I know in eclipse, projects main directory is *in* the classpath.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 04, 2004 6:17 pm 
Expert
Expert

Joined: Tue Sep 16, 2003 4:06 pm
Posts: 318
Location: St. Petersburg, Russia
Well, I know nothing about Eclipse but usually (in other IDEs), project root is not in the classpath. Usually classpath includes build directory which is not project root.
This is easy to check by examining command line used to launch your application. Again - not sure about Eclipse but both JBuilder and IDEA show this in the output window.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 05, 2004 5:26 pm 
Newbie

Joined: Mon Jan 05, 2004 5:11 pm
Posts: 1
Location: London, UK
As the previous reply states, in later versions of Eclipse the project root is not in the classpath by default - check your project properties to be sure, under Java Build Path.

You should also not put the hibernate.properties in the build output folder (usually /bin) - as this will get deleted whenever you rebuild the project. Instead place the properties in one of your source folders - (usually /src) - and it will get copied to /bin during the next build.


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