为了账号安全,请及时绑定邮箱和手机立即绑定

跟着老师敲的,这是什么问题导致

WARN: HHH000181: No appropriate connection provider encountered, assuming application will be supplying connections
Exception in thread "main" java.lang.ExceptionInInitializerError
    at com.imooc.test.Test.add(Test.java:37)
    at com.imooc.test.Test.main(Test.java:19)
Caused by: org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
    at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.determineDialect(DialectFactoryImpl.java:104)
    at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.buildDialect(DialectFactoryImpl.java:71)
    at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:209)
    at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:89)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:206)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:178)
    at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1885)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1843)
    at com.imooc.util.HibernateUtil.<clinit>(HibernateUtil.java:18)
    ... 2 more

正在回答

3 回答

你看看你加粗的这一行,是你的数据库方言dialect出错了,看看是否有jar包还是你的jar包不匹配的问题,又或者你输入的时候打错了。

WARN: HHH000181: No appropriate connection provider encountered, assuming application will be supplying connections
Exception in thread "main" java.lang.ExceptionInInitializerError
    at com.imooc.test.Test.add(Test.java:37)
    at com.imooc.test.Test.main(Test.java:19)
Caused by: org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
    at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.determineDialect(DialectFactoryImpl.java:104)
    at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.buildDialect(DialectFactoryImpl.java:71)
    at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:209)
    at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:89)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:206)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:178)
    at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1885)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1843)
    at com.imooc.util.HibernateUtil.<clinit>(HibernateUtil.java:18)
    ... 2 more

1 回复 有任何疑惑可以回复我~

将hibernate.cfg.xml改为下面的代码再试试,注意账户密码等个人配置得改为自己的哈

<!DOCTYPE hibernate-configuration PUBLIC

        "-//Hibernate/Hibernate Configuration DTD 3.0//EN"

        "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">

          

<hibernate-configuration>

<session-factory>

<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>

<property name="hibernate.connection.username">root</property>

<property name="hibernate.connection.password">123</property>

<property name="hibernate.connection.url">

        <![CDATA[

        jdbc:mysql://localhost:3306/imooc?characterEncoding=utf8

        ]]>

        </property>

        

<property name="hibernate.dialet">org.hibernate.dialect.MySQLDialect</property>


<property name="show_sql">true</property>

<property name="hbm2ddl.auto">update</property>

<!-- 指定映射文件的路径 -->

<mapping resource="com/imooc/entity/Grade.hbm.xml"/>

<mapping resource="com/imooc/entity/Student.hbm.xml"/>

</session-factory>

</hibernate-configuration>


0 回复 有任何疑惑可以回复我~
#1

如今正好 提问者

还是不行,说这一行Session session=HibernateUtil.getSession();和add();存在问题
2018-03-13 回复 有任何疑惑可以回复我~

重新看视频

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
Hibernate初探之一对多映射
  • 参与学习       42171    人
  • 解答问题       295    个

Hibernate中一对多关联映射配置,以及cascade和inverse属性作用

进入课程

跟着老师敲的,这是什么问题导致

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信