0

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

3
  • can you please post what are the jars are there in your classpath ? Commented Apr 14, 2011 at 10:14
  • it seems is a problem with your driver. post your hibernate.cfg.xml too please. Commented Apr 14, 2011 at 10:17
  • Following jar files are there: antlr-2.7.5H3.jar, antlr-2.7.6rc1.jar, asm.jar, c3p0-0.8.5.2.jar, cglib-2.1.3.jar, cglib-2.1.jar, dom4j-1.6.1.jar, dom4j-1.6.jar, hibernate3.jar, javassist-3.4.GA.jar jta.jar, log4j-1.2.9.jar, oscache-2.1.jar, oscache-2.2.jar, slf4j-api-1.5.2.jar, slf4j-log4j12-1.5.2.jar, swarmcache-1.0rc2.jar, mysql-connector-java-3.1.7-bin.jar Commented Apr 14, 2011 at 10:18

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for the reply, I have added hibernate3.jar which contains the SQLServerDialect class in it. But no use. It still showing same exceptions.
Pay attention, this are two different classes, one net.sf.hibernate one org.hibernate.
0

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

4 Comments

Mysqlserver.jar is not there but inplace of it I have "mysql-connector-java-3.1.7-bin.jar"
i wrote Mssqlserver.jar not Mysqlserver.jar oky
your goning to connect with MsSql db so use jar for that, not for mysql db.
oh sorry, my mistake.. I'll add that jar and try.. Thanks a lot.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.