zoukankan      html  css  js  c++  java
  • SSH hibernate 使用时最好添加访问数据库的编码

    SSH hibernate 使用时最好添加访问数据库的编码

    如下所示:第13行为设置hibernate访问数据库的编码(&是&的转义序列)

     1 <!DOCTYPE hibernate-configuration PUBLIC
     2         "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
     3         "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
     4 
     5 <!-- 这些信息都可以在官方目录下的properties文件中找到 -->
     6 <hibernate-configuration>
     7     <!-- 告诉hibernate怎么连接数据库,底层还是用jdbc访问的 -->
     8     <session-factory>
     9         <property name="connection.driver_class">
    10             com.mysql.jdbc.Driver
    11         </property>
    12         <property name="connection.url">
    13             jdbc:mysql://localhost:3306/hibernatetest?useUnicode=true&amp;characterEncoding=UTF-8
    14         </property>
    15         <property name="connection.username">root</property>
    16         <property name="connection.password">123</property>
    17 
    18         <property name="hibernate.dialect">
    19             org.hibernate.dialect.MySQLDialect
    20         </property>
    21         <!-- hibernate启动的时候将已有的表重新覆盖,使用create的话 -->
    22         <property name="hbm2ddl.auto">create-drop</property>
    23         <!-- 当hibernate运行时产生sql语句 -->
    24         <property name="show_sql">true</property>
    25 
    26         <!-- 以下是映射文件,这个是xml文件,用的是‘/’分隔符,如果是类,用的是'.'分割 -->
    27         <!--<mapping resource="com/hyy/hibernate/domain/Student.hbm.xml"/>-->
    28     </session-factory>
    29 </hibernate-configuration>
  • 相关阅读:
    雅虎军规34条 (一)
    jetty和tomcat的区别
    Jsp--9大内置对象
    java 重定向和转发的区别
    layer弹出层
    html 锚点
    css绘制三角形
    原生js下拉菜单联动
    layui省市区下拉菜单三级联动
    tp5时间格式转换
  • 原文地址:https://www.cnblogs.com/wuyou/p/3242076.html
Copyright © 2011-2022 走看看