• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate DAO error

 
S.R.K.Vivek Raju
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all

I have used hibernate3.jar and i wrote a DAO to persist data into the database, I wrote the following code and i am using a hibernate.properties file to set the hibernate.connection.url and register the database and set the dialect. I hibernate.properties is stored in WEB-INF classes.

The code is as follows

try{
System.out.println("************Hello World 1************");
config = new Configuration();
System.out.println("************Hello World 2************");
config.addClass(UserDataBO.class);
System.out.println("************Hello World 3************");
sessionFactory = config.buildSessionFactory();
System.out.println("************Hello World 4******************");
session = sessionFactory.openSession();

Transaction tx = session.beginTransaction();
System.out.println("*********Creating transaction*************");

session.save(userData);

session.flush();

tx.commit();

System.out.println("**************Committing**************");

session.close();
}

Then when i enter the data on the page and submit it gives the following code on my jboss console, the error is a follows:

10:28:39,156 INFO [STDOUT] ************Hello World 1************
10:28:39,156 INFO [STDOUT] ************Hello World 2************
10:28:39,156 INFO [Configuration] Mapping resource: com/businessobjects/UserDataBO.hbm
.xml
10:28:39,171 INFO [Binder] Mapping class: com.businessobjects.UserDataBO -> user
10:28:39,187 INFO [STDOUT] ************Hello World 3************
10:28:39,187 INFO [Configuration] processing one-to-many association mappings
10:28:39,187 INFO [Configuration] processing one-to-one association property reference
s
10:28:39,187 INFO [Configuration] processing foreign key constraints
10:28:39,187 WARN [SettingsFactory] No dialect set - using GenericDialect: The dialect
was not set. Set the property hibernate.dialect.
10:28:39,187 INFO [Dialect] Using dialect: org.hibernate.dialect.GenericDialect
10:28:39,187 INFO [SettingsFactory] Generate SQL with comments: disabled
10:28:39,187 INFO [SettingsFactory] Query language substitutions: {}
10:28:39,187 WARN [UserSuppliedConnectionProvider] No connection properties specified
- the user must supply JDBC connections
10:28:39,187 INFO [SettingsFactory] Scrollable result sets: disabled
10:28:39,187 INFO [SettingsFactory] JDBC3 getGeneratedKeys(): disabled
10:28:39,187 INFO [TransactionFactoryFactory] Using default transaction strategy (dire
ct JDBC transactions)
10:28:39,187 INFO [TransactionManagerLookupFactory] No TransactionManagerLookup config
ured (in JTA environment, use of process level read-write cache is not recommended)
10:28:39,187 INFO [SettingsFactory] Cache provider: org.hibernate.cache.EhCacheProvide
r
10:28:39,187 INFO [SettingsFactory] Second-level cache: enabled
10:28:39,187 INFO [SettingsFactory] Optimize cache for minimal puts: disabled
10:28:39,187 INFO [SettingsFactory] Query cache: disabled
10:28:39,187 INFO [SettingsFactory] Statistics: disabled
10:28:39,187 INFO [SettingsFactory] Deleted entity synthetic identifier rollback: disa
bled
10:28:39,187 INFO [SessionFactoryImpl] building session factory
10:28:39,203 INFO [SessionFactoryObjectFactory] Not binding factory to JNDI, no JNDI n
ame configured
10:28:39,203 INFO [SessionFactoryImpl] Checking 0 named queries
10:28:39,203 INFO [STDOUT] ************Hello World 4******************
10:28:39,218 WARN [RequestProcessor] Unhandled Exception thrown: class java.lang.Unsup
portedOperationException
10:28:39,218 ERROR [Engine] StandardWrapperValve[action]: Servlet.service() for servlet
action threw exception
java.lang.UnsupportedOperationException: The user must supply a JDBC connection
at org.hibernate.connection.UserSuppliedConnectionProvider.getConnection(UserSu
ppliedConnectionProvider.java:32)
at org.hibernate.jdbc.AbstractBatcher.openConnection(AbstractBatcher.java:338)
at org.hibernate.impl.SessionImpl.connect(SessionImpl.java:1629)
at org.hibernate.impl.SessionImpl.connection(SessionImpl.java:1609)
at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:40)
at org.hibernate.transaction.JDBCTransactionFactory.beginTransaction(JDBCTransa
ctionFactory.java:19)
at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1184)
at com.dao.RegisterDAO.registerUser(RegisterDAO.java:67)
at com.actions.RegisterAction.execute(RegisterAction.java:64)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProces
sor.java:421)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:226)

at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:157)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.ja
va:75)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:186)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
va:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex
t.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContext
Valve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
va:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex
t.java:104)
at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalVal
ve.java:44)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex
t.java:102)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssoci
ationValve.java:169)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex
t.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137
)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex
t.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118
)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex
t.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex
t.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConne
ction(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.jav
a:683)
at java.lang.Thread.run(Thread.java:534)
***************************************************************************
If any one has faced and a similsr problem or is aware of the problem please help me.

A thousand thanks in advance,

With Regards
S.R.K.Vivek Raju.
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i guess this:
10:28:39,218 ERROR [Engine] StandardWrapperValve[action]: Servlet.service() for servlet
action threw exception
java.lang.UnsupportedOperationException: The user must supply a JDBC connection

suggests you didnt provide a driver for your db
hope this helps
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic