Pls help me to get around this problem.
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)
|