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>
  • 相关阅读:
    AwaitAsync(异步和多线程)
    Newtonsoft.Json高级用法
    C# DataTable 去重复数据方法
    C# List 根据对象属性去重的四种方法对比
    C# <T>泛型的使用
    LeetCode 368. Largest Divisible Subset
    LeetCode 357. Count Numbers with Unique Digits
    LeetCode 350. Intersection of Two Arrays II
    LeetCode 349. Intersection of Two Arrays
    LeetCode 344. Reverse String
  • 原文地址:https://www.cnblogs.com/wuyou/p/3242076.html
Copyright © 2011-2022 走看看