Druid数据库连接池介绍.pptx
温绍锦(温高铁)http:/ DataSourceJboss DataSource(历史原因还在使用)稳定的特性-ExceptionSorter当连接产生不可恢复的异常时,需要及时从连接池中清除,否则会产生大量错误。这个功能也称为ExceptionSorter,只有JBossDataSource和DruidDataSource实现了这个功能。Oracle Fatal ExcetionError Code28Session has been killed600Internal oracle error1012Not logged on1014Oracle shutdown in progress1033Oracle initialization or shutdown in progress1034Oracle not available1035ORACLE only available to users with RESTRICTED SESSION privilege1089Immediate shutdown in progres no operations are permitted1090Shutdown in progress no operations are permitted1092ORACLE instance terminated.Disconnection forced1094ALTER DATABASE CLOSE in progress.Connections not permittedMySql Fatal ExceptionError Code1040ER_CON_COUNT_EEROR1042ER_BAD_HOST_ERRROR1043ER_HANDSHAKE_ERROR1047ER_UNKOWN_COM_ERROR1081ER_IPSOCK_ERROR1029ER_HOST_IS_BLOCKED1030ER_HOST_NOT_PRIVILEGED1045ER_ACCESS_DENIED_ERROR1004ER_CANT_CREATE_FILE1005ER_CANT_CREAT_TABLE1015ER_CANT_LOCK1021ER_DISK_FULL高性能1 线程程2 线程程5 线程程10 线程程20线程程50线程程Druid1,1021,5091,8891,9042,0071,977Tomcat-jdbc1,3991,3782,2572,2892,3052,503DBCP3,1443,8346,2766,4086,5636,783BoneCP4,3273,5983,8005,2429,40219,066Jboss-Datasource4,9123,0496,8686,51240,14643,748C3P018,57019,46715,27019,29428,19566,677Proxool16,22114,45524,68838,90548,087(Error)58,238(Error)详细测试信息:https:/ 线程2 线程5 线程10 线程20线程50线程01000020000300004000050000600007000080000DruidTomcat-jdbcDBCPBoneCPJboss-DatasourceC3P0ProxoolSQL ParserParser基本概念词法分析Token语法分析抽象语法树表达式语句手写Parser的性能Cobar的SQL Parser,从Antlr生成的parser修改为Druid Parser之后,大约提升6倍的性能。Druid Parser最近再次大幅度提升性能(50%)SQL Parser的关键在于词法词法分析要支持预测监控Spring关联监控Web关联监控查看SQL执行明细配置filters=log4j2013-07-12 16:10:17,966 DEBUG Connection:132-conn-10001 connected2013-07-12 16:10:17,970 DEBUG Connection:132-conn-10001 commited2013-07-12 16:10:17,970 DEBUG Connection:132-conn 10001 rollback2013-07-12 16:10:17,983 DEBUG Statement:137-conn-10001,stmt-20000 created2013-07-12 16:10:17,986 DEBUG Statement:137-conn-10001,stmt-20000 executed.0.052501 millis.SELECT 12013-07-12 16:10:17,986 DEBUG Statement:137-conn-10001,stmt-20000 batch executed.0.041842 millis.SELECT 12013-07-12 16:10:18,205 DEBUG Statement:137-conn-10001,stmt-20000,rs-50000 query executed.219.082247 millis.SELECT 12013-07-12 16:10:18,205 DEBUG ResultSet:142-conn-10001,stmt-20000,rs-50000 open2013-07-12 16:10:18,206 DEBUG ResultSet:142-conn-10001,stmt-20000,rs-50000 Header:null2013-07-12 16:10:18,206 DEBUG Statement:137-conn-10001,stmt-20000 update executed.effort 0.0.019343 millis.SELECT 12013-07-12 16:10:18,223 DEBUG Statement:137-conn-10001,pstmt-20001 created.SELECT 12013-07-12 16:10:18,260 DEBUG Statement:137-conn-10001,pstmt-20001 Parameters:null,null,null,null,com.alibaba.druid.mock.MockBlob34aee875,1,B471f7458,null,com.alibaba.druid.mock.MockClob620f61e2,null,1.0,1,1,null,com.alibaba.druid.mock.MockNClob5fe36eb9,null,null,null,com.alibaba.druid.mock.MockRef4c7a64dd,com.alibaba.druid.mock.MockRowId77741064,1,com.alibaba.druid.mock.MockSQLXML64e05280,null,null,null,null2013-07-12 16:10:18,260 DEBUG Statement:137-conn-10001,pstmt-20001 Types:ARRAY,OTHER,DECIMAL,OTHER,BLOB,TINYINT,OTHER,OTHER,CLOB,DATE,FLOAT,INTEGER,BIGINT,OTHER,NCLOB,NVARCHAR,VARCHAR,OTHER,REF,ROWID,SMALLINT,SQLXML,VARCHAR,TIME,TIMESTAMP,OTHER,OTHER2013-07-12 16:10:18,260 DEBUG Statement:137-conn-10001,pstmt-20001 executed.0.564872 millis.SELECT 12013-07-12 16:10:18,260 DEBUG Statement:137-conn-10001,pstmt-20001 batch executed.0.0075 millis.SELECT 12013-07-12 16:10:18,260 DEBUG Statement:137-conn-10001,pstmt-20001 Parameters:null,null,null,null,com.alibaba.druid.mock.MockBlob34aee875,1,B471f7458,null,com.alibaba.druid.mock.MockClob620f61e2,null,1.0,1,1,null,com.alibaba.druid.mock.MockNClob5fe36eb9,null,null,null,com.alibaba.druid.mock.MockRef4c7a64dd,com.alibaba.druid.mock.MockRowId77741064,1,com.alibaba.druid.mock.MockSQLXML64e05280,null,null,null,null2013-07-12 16:10:18,262 DEBUG Statement:137-conn-10001,pstmt-20001 Types:ARRAY,OTHER,DECIMAL,OTHER,BLOB,TINYINT,OTHER,OTHER,CLOB,DATE,FLOAT,INTEGER,BIGINT,OTHER,NCLOB,NVARCHAR,VARCHAR,OTHER,REF,ROWID,SMALLINT,SQLXML,VARCHAR,TIME,TIMESTAMP,OTHER,OTHER2013-07-12 16:10:18,262 DEBUG Statement:137-conn-10001,pstmt-20001,rs-50001 query executed.1.805932 millis.SELECT 12013-07-12 16:10:18,262 DEBUG ResultSet:142-conn-10001,pstmt-20001,rs-50001 open2013-07-12 16:10:18,263 DEBUG ResultSet:142-conn-10001,pstmt-20001,rs-50001 Header:null2013-07-12 16:10:18,263 DEBUG Statement:137-conn-10001,pstmt-20001 Parameters:null,null,null,null,com.alibaba.druid.mock.MockBlob34aee875,1,B471f7458,null,com.alibaba.druid.mock.MockClob620f61e2,null,1.0,1,1,null,com.alibaba.druid.mock.MockNClob5fe36eb9,null,null,null,com.alibaba.druid.mock.MockRef4c7a64dd,com.alibaba.druid.mock.MockRowId77741064,1,com.alibaba.druid.mock.MockSQLXML64e05280,null,null,null,null2013-07-12 16:10:18,263 DEBUG Statement:137-conn-10001,pstmt-20001 Types:ARRAY,OTHER,DECIMAL,OTHER,BLOB,TINYINT,OTHER,OTHER,CLOB,DATE,FLOAT,INTEGER,BIGINT,OTHER,NCLOB,NVARCHAR,VARCHAR,OTHER,REF,ROWID,SMALLINT,SQLXML,VARCHAR,TIME,TIMESTAMP,OTHER,OTHER2013-07-12 16:10:18,263 DEBUG Statement:137-conn-10001,pstmt-20001 update executed.effort 0.0.287765 millis.SELECT 12013-07-12 16:10:18,274 DEBUG Statement:137-conn-10001,cstmt-20002 created.SELECT 12013-07-12 16:10:18,274 DEBUG Statement:137-conn-10001,stmt-20000,rs-50002 query executed.0.081711 millis.SELECT 12013-07-12 16:10:18,274 DEBUG ResultSet:142-conn-10001,stmt-20000,rs-50002 open2013-07-12 16:10:18,274 DEBUG ResultSet:142-conn-10001,stmt-20000,rs-50002 Header:null2013-07-12 16:10:18,275 DEBUG ResultSet:142-conn-10001,stmt-20000,rs-50002 Result:1防御SQL注入配置filters=“wall”智能拦截永真条件智能拦截系统函数调用智能拦截系统表访问集中配置、动态配置filters=“config”支持数据库密码加密支持从本地或者http远程读取配置文件