hibernate4.3Hello 第一个程序遇到的坑 【给自己的总结】
2017-03-02 12:49
573 查看
看着官方文档一步一步来,环境就是搭不起来了,折腾了半天,看着网上的的入门教程是没有问题的,最后发现是使用的了hibernate4 hibernate.cfg.xml文件红色标记的部分
<?xml version ='1.0'encoding ='utf-8'?> < hibernate-configuration xmlns = “http://www.hibernate.org/xsd/hibernate-configuration” xsi:schemaLocation = “http://www.hibernate.org/xsd/hibernate-configuration hibernate-configuration-4.0.xsd” xmlns:xsi = “http://www.w3.org/2001/XMLSchema-instance” > < session-factory > <! - 数据库连接设置 - > < property name = “connection.driver_class” > org.hsqldb.jdbcDriver </ property > < property name = “connection.url” > jdbc:hsqldb:hsql:// localhost </ property > < property name = “connection.username” > sa </ property > < property name = “connection.password” > </ property > <! - JDBC连接池(使用内置) - > < property name = “connection.pool_size” > 1 </ property > <! - SQL方言 - > < property name = “dialect” > org.hibernate.dialect.HSQLDialect </ property > <! - 启用Hibernate的自动会话上下文管理 - > < property name = “current_session_context_class” > thread </ property > <! - 禁用二级缓存 - > < property name = “cache.provider_class” > org.hibernate.cache.internal.NoCacheProvider </ property > <! - 回显所有执行的SQL到stdout - > < property name = “show_sql” > true </ property > <! - 在启动时删除并重新创建数据库模式 - > < property name = “hbm2ddl.auto” > update </ property > < mapping resource = “org / hibernate / tutorial / domain / Event.hbm.xml” /> </ session-factory > </ hibernate-configuration >
把红色部分换成 黑色部分 ,程序终于可以正常运行
<?xml version='1.0' encoding='utf-8'?><!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="connection.driver_class">com.mysql.jdbc.Driver</property> <property name="connection.url">jdbc:mysql://127.0.0.1:3306/hibernate4?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true</property> <property name="connection.username">root</property> <property name="connection.password">1234</property> <property name="dialect">org.hibernate.dialect.MySQL5Dialect</property> <property name="current_session_context_class">thread</property> <property name="show_sql">true</property> <property name="hbm2ddl.auto">update</property> <!-- <mapping class="com.hibernate4.beans.User" /> --> <mapping resource="com/hibernate4/beans/user.hbm.xml"/> </session-factory></hibernate-configuration>
相关文章推荐
- 总结体验1:就比如上面自己写的单链表建立这样的程序,其实明明知道输出单链表不能从头结点开始输入,而是要在第一个节点开始
- Spark 安装及运行第一个程序遇到问题总结
- 编写第一个XML-RPC程序遇到的问题总结
- 第一个小程序---计算器开发中遇到的问题总结
- Android——第一个程序中遇到的问题总结
- 编写你的第一个Hibernate程序
- 编写osworkflow2.8+struts+hibernate的示例程序,遇到的持久化问题小解
- 自己编写的第一个程序!
- Hibernate入门02 - 第一个Hibernate程序
- Hibernate入门02 - 第一个Hibernate程序
- 自己复制粘贴出来的第一个java小程序
- 本人第一个能成功运行的hibernate程序
- 自己的第一个Javascript程序
- 自己写的第一个JAVA程序
- Hibernate 中遇到的一些问题(总结)
- Step By Step 如何写出自己的第一个JSP+JavaBean+Tomcat的程序
- 我的第一个完全自己写的C程序
- 调通了第一个Hibernate程序
- 在自己学习stuts是遇到问题后总结的经验。
- 用hibernate编写程序遇到的问题及解决方法