1, use DataSource, fill in the corresponding URL username and password can be!
<bean id= "DataSource" class= "Com.alibaba.druid.pool.DruidDataSource" init-method= "Init" destroy-method= "Close" > <!--Basic property URL, user, password-<property name= "url" value= "Your url"/> <property nam E= "username" value= "your username"/> <property name= "password" value= "Your password"/> <!--configuration initialization large Small, minimum, maximum--<property name= "InitialSize" value= "1"/> <property name= "Minidle" value= "1"/> <property name= "maxactive" value= "/> <!--configuration Get connection Wait timeout time--<property name=" maxwait "value=" 60000 "/> <!--configuration interval to detect the idle connection that needs to be closed, in milliseconds--and <property name=" Timebetweenevictionrunsmillis "va Lue= "60000"/> <!--Configure the minimum lifetime of a connection in the pool in milliseconds-and <property name= "Minevictableidletimemillis" value= "30 0000 "/> <property name=" validationquery "value=" select ' X ' "/> <property name=" Testwhileidle "value = "true"/> <property nAme= "Testonborrow" value= "false"/> <property name= "Testonreturn" value= "false"/> <!--if Oracle is used, the Poolpreparedstatements configured to True,mysql can be configured to False. A database with more sub-tables is recommended to be configured as false. -<!--open Pscache, and specify the size of Pscache on each connection-<property name= "poolpreparedstatements" value= "true"/> ; <property name= "maxpoolpreparedstatementperconnectionsize" value= "/> <!--Configuration Monitoring statistics interception filters--& Lt;property name= "Filters" value= "stat"/> </bean>
2. Add in Web. xml
<servlet> <servlet-name>DruidStatView</servlet-name> <servlet-class> com.alibaba.druid.support.http.statviewservlet</servlet-class> </servlet> < servlet-mapping> <servlet-name>DruidStatView</servlet-name> <url-pattern>/druid/* </url-pattern> </servlet-mapping>
3, because I use EXTJS development background, the monitoring page embedded in the ExtJS code as follows:
Ext.define (' Kl.view.DruidMonitor ', { extend: ' Ext.panel.Panel ', alias: ' Widget.druidmonitor ', height: , HTML: ' <iframe src=\ '. /.. /druid\ ' height=\ ' 100%\ ' width=\ ' 100%\ ' > </iframe> ', width:400, title: ' Database Monitoring ', Initcomponent:function () { var me = this; Me.callparent (arguments); }});
Last sticker:
Add database monitoring to your app (with Druid)