1、
hibernate.dialect' must be set when no Connection available错误
cfg=new AnnotationConfiguration().configure();
cfg=new AnnotationConfiguration().configure();
缺少的是configure();
添加这句话之后程序OK.
添加这句话之后程序OK.
new Configuration()默认是读取hibernate.properties
new Configuration()默认是读取hibernate.properties
new Configuration()默认是读取hibernate.properties
所以使用new Configuration().configure()来读取hibernate.cfg.xml文件
所以使用new Configuration().configure()来读取hibernate.cfg.xml文件
2、Exception in thread "main" org.hibernate.MappingException: Unknown entity:com.ygc.hibernate.modle.Teacher
2、Exception in thread "main" org.hibernate.MappingException: Unknown entity:com.ygc.hibernate.modle.Teacher
3ySQL 5中,出现错误提示:
Field 'id' doesn't have a default value
解决方法一:
打开my.ini,查找
sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
修改为
sql-mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
然后重启MYSQL
Field 'id' doesn't have a default value
解决方法一:
打开my.ini,查找
sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
修改为
sql-mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
然后重启MYSQL