hibernate dialect 问题
2008-10-11 1:04:24 org.hibernate.connection.UserSuppliedConnectionProvider configure
警告: No connection properties specified - the user must supply JDBC connections
org.hibernate.HibernateException: Hibernate Dialect must be explicitly set
at org.hibernate.dialect.DialectFactory.determineDialect(DialectFactory.java:57)
at org.hibernate.dialect.DialectFactory.buildDialect(DialectFactory.java:39)
at org.hibernate.cfg.SettingsFactory.determineDialect(SettingsFactory.java:437)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:132)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2078)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1302)
at com.hibernate.utils.HibernateTest.TestSave(HibernateTest.java:20)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at junit.framework.TestCase.runTest(TestCase.java:164)
at junit.framework.TestCase.runBare(TestCase.java:130)
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:120)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
请各位大虾 给小弟看看 这是什么原因 数据库方言在hibernate配置文件中已经正确配置了 但是还是出现这个问题
<session-factory>
<property name="connection.username">root</property>
<property name="connection.url">
jdbc:mysql://localhost:3306/test
</property>
<property name="dialect">
org.hibernate.dialect.MySQLDialect
</property>
<property name="myeclipse.connection.profile">
mysql
</property>
<property name="connection.password">
gf851012
</property>
<property name="hibernate.connection.driver_class">
com.mysql.jdbc.Driver
</property>
<property name="show_sql">true</property>
<mapping resource="com/hibernate/dao/Events.hbm.xml" />
</session-factory>
我在线等待各位的答案 谢谢 十分感谢!!!
[解决办法]
hibernate.cfg.xml 放哪了
[解决办法]
[解决办法]
换为以下内容试一下:
<session-factory>
<property name="connection.username">root </property>
<property name="connection.url">
jdbc:mysql://localhost:3306/test
</property>
<property name="dialect">
org.hibernate.dialect.MySQLInnoDBDialect
</property>
<property name="myeclipse.connection.profile">
mysql
</property>
<property name="connection.password">
gf851012
</property>
<property name="hibernate.connection.driver_class">
com.mysql.jdbc.Driver
</property>
<property name="show_sql">true </property>
<mapping resource="com/hibernate/dao/Events.hbm.xml" />
</session-factory>
[解决办法]
<property name="connection.user">
用户名没有配置!
</property>
hibernate.cfg.xml不能在src下面放着!
要放到classpath的路径下面,就是编译好的类路径下面,才能读取到!!!
[解决办法]
驱动是否加入到classpath中
hibernate.cfg.xml一般是放在src的根目录下,编译后在在输入的根目录下应该也要有,不然加载不到
config.addClass(XXX.class);//自己指定.class文件
[解决办法]
return hibernateSession;
}
else{
return localSession.get();
}
}
public static void closeSession(){
if(localSession.get()!=null){
localSession.set(null);
}
}
public static void main(String []str){
Session sission = getHibenateSession();
System.out.println(sission.connection());
}
}
看看创建链接是否成功
[解决办法]
1:驱动JAR有没有在环境变量里
2:从org.hibernate.HibernateException: Hibernate Dialect must be explicitly set 可以推断,根本咩有读取到你的配置信息
3:把你的测试类贴出来