-->
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.  [ 7 posts ] 
Author Message
 Post subject: JDBC connection error
PostPosted: Mon Jan 31, 2005 10:58 am 
Newbie

Joined: Mon Jan 31, 2005 10:47 am
Posts: 6
I'm new to using Hibernate, I read some doc and trying to save my first object to db, here's the code I'm using, and the stack trace of the exception I get:

Hibernate version:2.1

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();


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 hello.Message.main(Message.java:61)


Name and version of the database you are using:Oracle8i Enterprise Edition Release 8.1.7.0.0

and here's the contents of my hibernate.properties:

hibernate.connection.driver_class=oracle.jdbc.driver.OracleDriver
hibernate.connection.url=jdbc:oracle:thin:@linuxdev05.intra.it:1521:LINUXMF
hibernate.connection.username=mbank
hibernate.connection.password=mbank
hibernate.dialect=net.sf.hibernate.dialect.OracleDialect
hibernate.c3p0.min_size=5
hibernate.c3p0.max_size=20
hibernate.c3p0.timeout=300
hibernate.c3p0.max_statements=50
hibernate.c3p0.idle_test_period=3000

Can you help me?
Thank you.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 31, 2005 12:14 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
have haven't set your connection provider.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 31, 2005 2:45 pm 
Newbie

Joined: Mon Jan 31, 2005 10:47 am
Posts: 6
can you tell me how to do that?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 31, 2005 2:53 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
look connection provider up in the reference documentation.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 01, 2005 7:59 am 
Newbie

Joined: Mon Jan 31, 2005 10:47 am
Posts: 6
read documentation,
modified my hibernate.properties:

hibernate.connection.provider_class=net.sf.hibernate.connection.C3P0ConnectionProvider

hibernate.dialect=net.sf.hibernate.dialect.OracleDialect
hibernate.connection.driver_class=oracle.jdbc.driver.OracleDriver
hibernate.connection.url=jdbc:oracle:thin:@host:1521:sid
hibernate.connection.username=user
hibernate.connection.password=pwd

hibernate.c3p0.min_size=1
hibernate.c3p0.max_size=1
hibernate.c3p0.timeout=1800
hibernate.c3p0.max_statements=50

...still does not work :( i get the same error

dont want to be spoonfed but the beginnings are often troublesome, and the settings are overwhelming...

thanks


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 01, 2005 9:14 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
the error states that it is using the UserSuppliedConnectionProvider - hinting that it is either not seeing your hibernate.properties file and/or some issues with not being able to access the c3po provider.

Enable debug logging and see what it tells you.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 01, 2005 9:14 am 
Newbie

Joined: Mon Jan 31, 2005 10:47 am
Posts: 6
I GOT IT!!!!!!
I was trying to use hibernate.properties in my classpath but I was also calling setProperties on Configuration!

Code:
Configuration cfg = new Configuration()
       .addClass(hello.Message.class)
       .setProperties(System.getProperties());


took out .setProperties(System.getProperties())
works pretty fine
:)


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