-->
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: The user must supply a JDBC connection
PostPosted: Wed Jul 05, 2006 7:51 am 
Newbie

Joined: Thu Jun 29, 2006 8:55 am
Posts: 2
I am new to Hibernate.I am using Hibernate 2.1.
I am using mysql, i create a database "cdviewer".

I created a datasource link using tomcat as below

In the tomcat admin console i done the following things to create a datasource.
In the left panel i click the "Resources ->Data Sources " link and i fill the following values
JNDI Name = jdbc/pullcd
Data Source URL: = jdbc:mysql://localhost/cdviewer
JDBC Driver Class = com.mysql.jdbc.Driver
and username and password also.

After that i click the "Service ->Hosts->Context(/cdviewer)-->Resources-->ResourceLink "
I fill the following values

Name: jdbc/pullcd
Global: jdbc/pullcd
Type :javax.sql.DataSource

After done this , i create a folder "cdviewer" in webapps of tomcat .

I put "hibernate.cfg.xml" file inside /WEB-INF/class folder


<hibernate-configuration>
<session-factory>
<property name="connection.datasource">java:comp/env/jdbc/pullcd</property>
<property name="show_sql">true</property>
<property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>
<mapping resource="CD.hbm.xml"/>
</session-factory>
</hibernate-configuration>


And i written the mapping file also(/WEB-INF/classes/CD>hbm.xml).

My servlet code is
-------------------------------------------------------------------------------------
sessionFactory = new Configuration().addClass(CD.class).buildSessionFactory();

Session session = sessionFactory.openSession();
List cds = session.find("from CD");
-------------------------------------------------------------------------------------
But the following error occurs while accessing the application

java.lang.UnsupportedOperationException: The user must supply a JDBC connection
at net.sf.hibernate.connection.UserSuppliedConnectionProvider.getConnection(UserSuppliedConn
ectionProvider.java:32)
at net.sf.hibernate.impl.BatcherImpl.openConnection(BatcherImpl.java:286)
at net.sf.hibernate.impl.SessionImpl.connect(SessionImpl.java:3326)
at net.sf.hibernate.impl.SessionImpl.connection(SessionImpl.java:3286)
at net.sf.hibernate.impl.BatcherImpl.prepareQueryStatement(BatcherImpl.java:65)
at net.sf.hibernate.loader.Loader.prepareQueryStatement(Loader.java:779)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:265)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
at net.sf.hibernate.loader.Loader.doList(Loader.java:1033)
at net.sf.hibernate.loader.Loader.list(Loader.java:1024)
at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:854)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1544)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1521)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1513)
at CDViewer.displayAll(CDViewer.java:51)
at CDViewer.doGet(CDViewer.java:89)
at CDViewer.doPost(CDViewer.java:105)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.j
ava:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11P
rotocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.ja
va:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Unknown Source)


Top
 Profile  
 
 Post subject: Connection is NOT supplied
PostPosted: Thu Jul 06, 2006 11:42 pm 
Beginner
Beginner

Joined: Thu Jul 06, 2006 11:09 pm
Posts: 25
The problem with Hibernate session is that, even if it is already instantiated, it doesn't have the mechanism to validate the Connection object its holding. You might need to verify if the connection object from the datasource is really passing through the hibernate SessionFactory.

I use this with Spring so I don't have to worry loading up the SessionFactory and DataSource. Spring has its own implementation to this.


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.