我过去用的是sql server 2000与hibernate结合.
现在改用mysql 与hibernate结合后配制hibernate.cfg.xml出现异常:
org.hibernate.HibernateException: Dialect class not found: net.sf.hibernate.dialect.MySQLDialect
at org.hibernate.dialect.DialectFactory.buildDialect(DialectFactory.java:81)
at org.hibernate.dialect.DialectFactory.buildDialect(DialectFactory.java:42)
at org.hibernate.cfg.SettingsFactory.determineDialect(SettingsFactory.java:374)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:110)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1463)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1004)
at mysql.MySqlSession.initFactory(MySqlSession.java:5
at mysql.test.MySQLFirstTest.setUp(MySQLFirstTest.java:1
at junit.framework.TestCase.runBare(TestCase.java:125)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:11
at junit.framework.TestSuite.runTest(TestSuite.java:20
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:47
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
mysql的hibernate.cfg.xml配制如下:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">
org.gjt.mm.mysql.Driver
</property>
<property name="hibernate.connection.url">jdbc:myserver://localhost:3306;DatabaseName=shitest</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password"></property>
<property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>
<!-- property name="hibernate.connection.pool_size"></property -->
<!-- show sql log for debug -->
<property name="hibernate.show_sql">true</property>
<!-- use database out join -->
<property name="hibernate.use_outer_join">true</property>
<!-- type of transaction management -->
<property name="hibernate.transaction.factory_class">
net.sf.hibernate.transaction.JDBCTransactionFactory
</property>
<!-- pojo hbm mapping start -->
<mapping resource="mysql/po/MyFirstTest.hbm.xml"/>
<!-- pojo hbm mapping end -->
</session-factory>
</hibernate-configuration>
我在JSP页面直接访问mysql已没有问题了的.
根据异常说dialect的配制找不到.
请问我那差什么没有配制呢?
网上找了一下,也没有找到.
请知道帮忙一下.
先多谢了.
--转自