码迷,mamicode.com
首页 > 数据库 > 详细

jdbc.properties+web.xml

时间:2018-08-18 11:38:58      阅读:248      评论:0      收藏:0      [点我收藏+]

标签:ola   tco   config   max   数据   str   乱码   encoding   col   

1. jdbc.properties

#\u8FDE\u63A5\u8BBE\u7F6E
jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql:///数据库名
jdbc.username=账户
jdbc.password=密码

#<!-- \u521D\u59CB\u5316\u8FDE\u63A5 -->
initialSize=10

#\u6700\u5927\u8FDE\u63A5\u6570\u91CF
maxActive=50

#<!-- \u6700\u5927\u7A7A\u95F2\u8FDE\u63A5 -->
maxIdle=20

#<!-- \u6700\u5C0F\u7A7A\u95F2\u8FDE\u63A5 -->
minIdle=5

#<!-- \u8D85\u65F6\u7B49\u5F85\u65F6\u95F4\u4EE5\u6BEB\u79D2\u4E3A\u5355\u4F4D 6000\u6BEB\u79D2/1000\u7B49\u4E8E60\u79D2 -->
maxWait=60000


#JDBC\u9A71\u52A8\u5EFA\u7ACB\u8FDE\u63A5\u65F6\u9644\u5E26\u7684\u8FDE\u63A5\u5C5E\u6027\u5C5E\u6027\u7684\u683C\u5F0F\u5FC5\u987B\u4E3A\u8FD9\u6837\uFF1A[\u5C5E\u6027\u540D=property;] 
#\u6CE8\u610F\uFF1A"user" \u4E0E "password" \u4E24\u4E2A\u5C5E\u6027\u4F1A\u88AB\u660E\u786E\u5730\u4F20\u9012\uFF0C\u56E0\u6B64\u8FD9\u91CC\u4E0D\u9700\u8981\u5305\u542B\u4ED6\u4EEC\u3002
connectionProperties=useUnicode=true;characterEncoding=gbk

#\u6307\u5B9A\u7531\u8FDE\u63A5\u6C60\u6240\u521B\u5EFA\u7684\u8FDE\u63A5\u7684\u81EA\u52A8\u63D0\u4EA4\uFF08auto-commit\uFF09\u72B6\u6001\u3002
defaultAutoCommit=true

#driver default \u6307\u5B9A\u7531\u8FDE\u63A5\u6C60\u6240\u521B\u5EFA\u7684\u8FDE\u63A5\u7684\u4E8B\u52A1\u7EA7\u522B\uFF08TransactionIsolation\uFF09\u3002
#\u53EF\u7528\u503C\u4E3A\u4E0B\u5217\u4E4B\u4E00\uFF1A\uFF08\u8BE6\u60C5\u53EF\u89C1javadoc\u3002\uFF09NONE,READ_UNCOMMITTED, READ_COMMITTED, REPEATABLE_READ, SERIALIZABLE
defaultTransactionIsolation=READ_UNCOMMITTED

 

 

2.web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
         id="WebApp_ID" version="3.1">

    <!-- 读取SpringMVC -->
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:applicationContext.xml</param-value>
    </context-param>
    <!-- 启动Spring的监听器 -->
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <!--  配置解决中文乱码的问题 -->
    <filter>
        <filter-name>characterEncodingFilter</filter-name>
        <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
        <init-param>
            <param-name>encoding</param-name>
            <param-value>UTF-8</param-value>
        </init-param>
        <init-param>
            <param-name>forceEncoding</param-name>
            <param-value>true</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>characterEncodingFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <!-- 配置核心控制器-->
    <servlet>
        <servlet-name>dispatcher</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <!-- 告诉SpringMVC到哪里去找配置文件 -->
            <param-name>contextConfigLocation</param-name>
            <!-- 注意:这里只读取springmvc的xml -->
            <param-value>classpath:applicationContext-mvc.xml</param-value>
        </init-param>
        <!-- Servlet默认在每一次访问的时候创建 -->
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>dispatcher</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>
</web-app>

 

jdbc.properties+web.xml

标签:ola   tco   config   max   数据   str   乱码   encoding   col   

原文地址:https://www.cnblogs.com/daydayhave/p/9496313.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!