编程开发 > JSP > 文章内容

JSPSpring中Druid连接池配置详解

2017-4-29编辑:ljnbset

JSP Spring中Druid连接池配置详解

jdbc.properties

?

1

2

3

url=jdbc:postgresql://***.***.***.***:****/****

username=***

password=***

applicationContext.xml中配置bean

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

 <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close"

  

  <property name="url" value="${url}" />

  <property name="username" value="${username}" />

  <property name="password" value="${password}" />

 

  

  <property name="initialSize" value="1" />

  <property name="minIdle" value="1" /> 

  <property name="maxActive" value="20" />

 

  

  <property name="maxWait" value="60000" />

 

  

  <property name="timeBetweenEvictionRunsMillis" value="60000" />

 

  

  <property name="minEvictableIdleTimeMillis" value="300000" />

 

  <property name="validationQuery" value="SELECT 'x'" />

  <property name="testWhileIdle" value="true" />

  <property name="testOnBorrow" value="false" />

  <property name="testOnReturn" value="false" />

 

  

  <property name="poolPreparedStatements" value="true" />

  <property name="maxPoolPreparedStatementPerConnectionSize" value="20" />

 

  

  <property name="filters" value="stat" /> 

bean>

监控配置web.xml

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

<filter>

    <filter-name>DruidWebStatFilterfilter-name>

    <filter-class>com.alibaba.druid.support.http.WebStatFilterfilter-class>

    <init-param>

      <param-name>exclusionsparam-name>

      <param-value>*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*param-value>

    init-param>

  filter>

  <filter-mapping>

    <filter-name>DruidWebStatFilterfilter-name>

    <url-pattern>/*url-pattern>

  filter-mapping>

 

  <servlet>

    <servlet-name>DruidStatViewservlet-name>

    <servlet-class>com.alibaba.druid.support.http.StatViewServletservlet-class>

  servlet>

  <servlet-mapping>

    <servlet-name>DruidStatViewservlet-name>

    <url-pattern>/druid/*url-pattern>

  servlet-mapping>

img的src地址是一个请求的方式来显示图片方法

热点推荐

登录注册
触屏版电脑版网站地图