Uday
Uday

Reputation: 165

Exception in hibernate sample program

I'm trying a sample hibernate program, to connect to MS SQL DB and execute some sql. I've created hbm and cfg.xml files but while executing I'm getting following exception.

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.cfg.SettingsFactory.buildSettings(SettingsFactory.java:111)
    at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2101)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1325)
    at com.persistent.demo.HibernateUtil.<clinit>(HibernateUtil.java:12)
    at com.persistent.demo.HelloWorld.main(HelloWorld.java:15)
Exception in thread "main" java.lang.ExceptionInInitializerError
    at com.persistent.demo.HibernateUtil.<clinit>(HibernateUtil.java:14)
    at com.persistent.demo.HelloWorld.main(HelloWorld.java:15)
Caused by: org.hibernate.HibernateException: Dialect class not found: net.sf.hibernate.dialect.SQLServerDialect

I'm not getting whether I have missed any jar files or is there any other problem. Please help.

Thanks. -Uday

Upvotes: 0

Views: 1402

Answers (2)

Ralph
Ralph

Reputation: 120761

Dialect class not found: net.sf.hibernate.dialect.SQLServerDialect

You need to put the Jar, containing this class, in your class paht.

May the problem is, that the dialect you need is: org.hibernate.dialect.SQLServerDialect which is aviable in the hibernate core jar.

Upvotes: 2

p27
p27

Reputation: 2222

have you add Mssqlserver.jar in your class path . or check your connection url

Upvotes: 0

Related Questions