views:

38

answers:

3
+2  Q: 

hibernate problem

I am new to hibernate , am getting the following error

[INFO ][main][2010-07-16 17:36:13] HibernateUtil.java (l.66) : connection url =
jdbc:derby:MATOSO_DB;create=true
[ERROR][main][2010-07-16 17:36:14] SchemaExport.java (l.274) : schema export uns
uccessful
java.sql.SQLException: No suitable driver
        at java.sql.DriverManager.getConnection(DriverManager.java:545)
        at java.sql.DriverManager.getConnection(DriverManager.java:140)
        at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:133)
        at org.hibernate.tool.hbm2ddl.SuppliedConnectionProviderConnectionHelper.prepare(SuppliedConnectionProviderConnectionHelper.java:51)
        at org.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:252)
        at org.hibernate.tool.hbm2ddl.SchemaExport.create(SchemaExport.java:211)    
        at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:353)
        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1341)
        at org.mahjong.matoso.util.HibernateUtil.<clinit>(HibernateUtil.java:67)    
        at org.mahjong.matoso.servlet.init.ServletInit.init(ServletInit.java:40)    
        at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1173)
        at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:993)
        at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4350)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:4659)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546)
        at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1041)
        at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:964)
        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:502)
        at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1277)
        at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:321)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
        at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
        at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445)
        at org.apache.catalina.core.StandardService.start(StandardService.java:519)
        at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
[INFO ][main][2010-07-16 17:36:14] ServletInit.java (l.41) : *******************
********* Hibernate successfully initialized in 1094 ms
Jul 16, 2010 5:36:14 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory ROOT
Jul 16, 2010 5:36:14 PM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
Jul 16, 2010 5:36:14 PM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
Jul 16, 2010 5:36:14 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/16  config=null
Jul 16, 2010 5:36:14 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 10878 ms
+1  A: 

Probably the Derby JDBC driver is not in the classpath of your tomcat. Go to Apache Derby: Downloads and download the latest release. Add the driver jar (derby.jar from the lib folder of the archive) to the lib folder of your tomcat.

Daniel Murygin
+1  A: 

No suitable driver typically indicates a poorly formatted URL - assuming the driver has been loaded. So, double check:

  • that derby.jar in on the classpath,
  • that you specified the right driver class (should be org.apache.derby.jdbc.EmbeddedDriver if you're using Derby embedded),
  • that your URL doesn't contain spaces: jdbc:derby:MATOSO_DB;create=true (I reformatted the question but the initial version had spaces in the URL connection string).
Pascal Thivent
A: 

Try using the database URL:

jdbc:derby:MATOSO_DB;create=true

instead of:

jdbc: derby:MATOSO_DB; create = true
Thomas Mueller